From ba02069a8e22985a9a775dac9ece6dc54a7e8b44 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Fri, 23 Mar 2012 02:34:32 +0100 Subject: [PATCH] aacdec: prevent channels from exceeding MAX_CHANNELS. Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind Signed-off-by: Michael Niedermayer --- libavcodec/aacdec.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libavcodec/aacdec.c b/libavcodec/aacdec.c index f0ed667944..7c3d43a669 100644 --- a/libavcodec/aacdec.c +++ b/libavcodec/aacdec.c @@ -149,6 +149,10 @@ static av_cold int che_configure(AACContext *ac, ff_aac_sbr_ctx_init(ac, &ac->che[type][id]->sbr); } if (type != TYPE_CCE) { + if (*channels >= MAX_CHANNELS - (type == TYPE_CPE || (type == TYPE_SCE && ac->m4ac.ps == 1))) { + av_log(ac->avctx, AV_LOG_ERROR, "Too many channels\n"); + return AVERROR_INVALIDDATA; + } ac->output_data[(*channels)++] = ac->che[type][id]->ch[0].ret; if (type == TYPE_CPE || (type == TYPE_SCE && ac->m4ac.ps == 1)) {