avcodec/mpegvideo_enc: Clip bits_per_raw_sample within valid range
authorMichael Niedermayer <michael@niedermayer.cc>
Wed, 6 Jan 2016 23:22:56 +0000 (00:22 +0100)
committerMichael Niedermayer <michael@niedermayer.cc>
Sat, 30 Jan 2016 23:25:20 +0000 (00:25 +0100)
Fixes out of array read
Fixes: test_case-mdc.264 (b47be15a120979f5a1a945c938cbef33)

Found-by: Tyson Smith <twsmith@mozilla.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 13f266b50cc7554028d22480b7e4383968e64a63)

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavcodec/mpegvideo_enc.c

index 9bec400..9e53b5c 100644 (file)
@@ -316,6 +316,7 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx)
         break;
     }
 
+    avctx->bits_per_raw_sample = av_clip(avctx->bits_per_raw_sample, 0, 8);
     s->bit_rate = avctx->bit_rate;
     s->width    = avctx->width;
     s->height   = avctx->height;