mjpeg_decode_dc: check code before using it in get_xbits()
authorMichael Niedermayer <michaelni@gmx.at>
Sat, 29 Jun 2013 23:01:24 +0000 (01:01 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Sat, 29 Jun 2013 23:35:22 +0000 (01:35 +0200)
Fixes undefined behavior

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

index ef8e1c6..97a9ac9 100644 (file)
@@ -493,7 +493,7 @@ static inline int mjpeg_decode_dc(MJpegDecodeContext *s, int dc_index)
 {
     int code;
     code = get_vlc2(&s->gb, s->vlcs[0][dc_index].table, 9, 2);
-    if (code < 0) {
+    if (code < 0 || code > 16) {
         av_log(s->avctx, AV_LOG_WARNING,
                "mjpeg_decode_dc: bad vlc: %d:%d (%p)\n",
                0, dc_index, &s->vlcs[0][dc_index]);