ac3enc: return error if frame+exponent bits are too large instead of using
authorJustin Ruggles <justin.ruggles@gmail.com>
Fri, 15 Apr 2011 23:56:42 +0000 (19:56 -0400)
committerJustin Ruggles <justin.ruggles@gmail.com>
Sun, 1 May 2011 17:32:03 +0000 (13:32 -0400)
av_assert2().

This can occur in some very rare cases with low bitrates.

libavcodec/ac3enc.c

index 00cb047..47fd9b6 100644 (file)
@@ -1052,7 +1052,8 @@ static int cbr_bit_allocation(AC3EncodeContext *s)
     int snr_offset, snr_incr;
 
     bits_left = 8 * s->frame_size - (s->frame_bits + s->exponent_bits);
-    av_assert2(bits_left >= 0);
+    if (bits_left < 0)
+        return AVERROR(EINVAL);
 
     snr_offset = s->coarse_snr_offset << 4;