wavpackenc: assert on too small buffer
authorChristophe Gisquet <christophe.gisquet@gmail.com>
Tue, 19 Aug 2014 12:05:56 +0000 (14:05 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Thu, 21 Aug 2014 15:59:06 +0000 (17:59 +0200)
bytestream2_* will not cause buffer overflow, but in that case, this means
the allocation would be incorrect and the encoded result invalid. Therefore,
assert no overflow occurred.

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

index 005cf7c..3631a08 100644 (file)
@@ -2813,6 +2813,8 @@ static int wavpack_encode_block(WavPackEncodeContext *s,
     block_size = bytestream2_tell_p(&pb);
     AV_WL32(out + 4, block_size - 8);
 
+    av_assert0(put_bits_left(&s->pb) > 0);
+
     return block_size;
 }