mpc8: fix channel checks
authorMichael Niedermayer <michaelni@gmx.at>
Sun, 3 Jun 2012 15:40:30 +0000 (17:40 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Sat, 9 Jun 2012 18:50:14 +0000 (20:50 +0200)
fix heap array overflow

Found-by: Piotr Bandurski <ami_stuff@o2.pl>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
(cherry picked from commit 44c10168cff41c200825448b77cb8feff0d316c9)

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavcodec/mpc8.c

index a4750ad..ebf00e1 100644 (file)
@@ -138,7 +138,8 @@ static av_cold int mpc8_decode_init(AVCodecContext * avctx)
     c->frames = 1 << (get_bits(&gb, 3) * 2);
 
     avctx->sample_fmt = AV_SAMPLE_FMT_S16;
-    avctx->channel_layout = (avctx->channels==2) ? AV_CH_LAYOUT_STEREO : AV_CH_LAYOUT_MONO;
+    avctx->channel_layout = (channels==2) ? AV_CH_LAYOUT_STEREO : AV_CH_LAYOUT_MONO;
+    avctx->channels = channels;
 
     if(vlc_initialized) return 0;
     av_log(avctx, AV_LOG_DEBUG, "Initing VLC\n");