ape_decode_value_3860: check k before using it in get_bits()
authorMichael Niedermayer <michaelni@gmx.at>
Thu, 2 May 2013 15:24:02 +0000 (17:24 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Thu, 2 May 2013 15:24:02 +0000 (17:24 +0200)
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavcodec/apedec.c

index be6edd2..1f55dab 100644 (file)
@@ -489,9 +489,12 @@ static inline int ape_decode_value_3860(APEContext *ctx, GetBitContext *gb,
 
     if (!rice->k)
         x = overflow;
-    else
+    else if(rice->k <= MIN_CACHE_BITS) {
         x = (overflow << rice->k) + get_bits(gb, rice->k);
-
+    } else {
+        av_log(ctx->avctx, AV_LOG_ERROR, "Too many bits: %d\n", rice->k);
+        return AVERROR_INVALIDDATA;
+    }
     rice->ksum += x - (rice->ksum + 8 >> 4);
     if (rice->ksum < (rice->k ? 1 << (rice->k + 4) : 0))
         rice->k--;