put_bits: fix invalid shift by 32 in flush_put_bits()

If flush_put_bits() is called when the 32-bit buffer is empty,
e.g. after writing a multiple of 32 bits, and invalid shift by
32 is performed.  Since flush_put_bits() is called infrequently,
this additional check should have negligible performance impact.

Signed-off-by: Mans Rullgard <mans@mansr.com>
This commit is contained in:
Mans Rullgard 2011-10-08 02:09:42 +01:00
parent 98ef887a75
commit ac6eab1496
1 changed files with 2 additions and 1 deletions

View File

@ -78,6 +78,7 @@ static inline int put_bits_count(PutBitContext *s)
static inline void flush_put_bits(PutBitContext *s) static inline void flush_put_bits(PutBitContext *s)
{ {
#ifndef BITSTREAM_WRITER_LE #ifndef BITSTREAM_WRITER_LE
if (s->bit_left < 32)
s->bit_buf<<= s->bit_left; s->bit_buf<<= s->bit_left;
#endif #endif
while (s->bit_left < 32) { while (s->bit_left < 32) {