From 1c638cfc25fdba1369ebd16aa7c8393a73ef9801 Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Tue, 3 Jul 2012 11:16:56 +0000 Subject: [PATCH] jvdec: stop reading partial palette Signed-off-by: Paul B Mahol --- libavcodec/jvdec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/jvdec.c b/libavcodec/jvdec.c index 728b749896..acf1885611 100644 --- a/libavcodec/jvdec.c +++ b/libavcodec/jvdec.c @@ -174,8 +174,8 @@ static int decode_frame(AVCodecContext *avctx, } } - if (buf < buf_end) { - for (i = 0; i < AVPALETTE_COUNT && buf + 3 <= buf_end; i++) { + if (buf_end - buf >= AVPALETTE_COUNT * 3) { + for (i = 0; i < AVPALETTE_COUNT; i++) { uint32_t pal = AV_RB24(buf); s->palette[i] = 0xFF << 24 | pal << 2 | ((pal >> 4) & 0x30303); buf += 3;