avcodec/cavsdec: Check esc_code
authorMichael Niedermayer <michaelni@gmx.at>
Thu, 14 May 2015 15:54:40 +0000 (17:54 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Fri, 15 May 2015 08:04:51 +0000 (10:04 +0200)
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
(cherry picked from commit 139e1c8009df7729a53eaaae7036ca01071aced5)

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

index cffb19c..834092f 100644 (file)
@@ -563,6 +563,11 @@ static int decode_residual_block(AVSContext *h, GetBitContext *gb,
                 return AVERROR_INVALIDDATA;
             }
             esc_code = get_ue_code(gb, esc_golomb_order);
+            if (esc_code < 0 || esc_code > 32767) {
+                av_log(h->avctx, AV_LOG_ERROR, "esc_code invalid\n");
+                return AVERROR_INVALIDDATA;
+            }
+
             level    = esc_code + (run > r->max_run ? 1 : r->level_add[run]);
             while (level > r->inc_limit)
                 r++;