From dffae122d0f448029c30afc672233f114a3fe09c Mon Sep 17 00:00:00 2001
From: Michael Niedermayer <michael@niedermayer.cc>
Date: Wed, 15 Jul 2015 04:59:35 +0200
Subject: [PATCH] avcodec/mjpegdec: Fix DC overflow in decode_block()

Fixes Ticket4683

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavcodec/mjpegdec.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
index f85eabfe4d..8094274ff6 100644
--- a/libavcodec/mjpegdec.c
+++ b/libavcodec/mjpegdec.c
@@ -672,6 +672,7 @@ static int decode_block(MJpegDecodeContext *s, int16_t *block, int component,
         return AVERROR_INVALIDDATA;
     }
     val = val * quant_matrix[0] + s->last_dc[component];
+    val = FFMIN(val, 32767);
     s->last_dc[component] = val;
     block[0] = val;
     /* AC coefs */