From 6d6eabd399eb20b69d10234ef746f2d3d4c72dcb Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Sun, 30 Jun 2013 01:01:24 +0200 Subject: [PATCH] mjpeg_decode_dc: check code before using it in get_xbits() Fixes undefined behavior Signed-off-by: Michael Niedermayer --- libavcodec/mjpegdec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c index ef8e1c6ba2..97a9ac996e 100644 --- a/libavcodec/mjpegdec.c +++ b/libavcodec/mjpegdec.c @@ -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]);