aboutsummaryrefslogtreecommitdiff
path: root/libavcodec/put_bits.h
diff options
context:
space:
mode:
authorMans Rullgard2011-10-08 02:09:42 +0100
committerMans Rullgard2011-10-08 02:41:58 +0100
commitac6eab1496aad6f8b09deabbef4fe5fd829e142d (patch)
tree48f34a0725a7da2f72dfe757bdf90f1a1f6d0dfc /libavcodec/put_bits.h
parent98ef887a759c66febcb612407c6bb361c4d50bcb (diff)
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>
Diffstat (limited to 'libavcodec/put_bits.h')
-rw-r--r--libavcodec/put_bits.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/libavcodec/put_bits.h b/libavcodec/put_bits.h
index c10dd818f0..f77cfbba97 100644
--- a/libavcodec/put_bits.h
+++ b/libavcodec/put_bits.h
@@ -78,7 +78,8 @@ static inline int put_bits_count(PutBitContext *s)
static inline void flush_put_bits(PutBitContext *s)
{
#ifndef BITSTREAM_WRITER_LE
- s->bit_buf<<= s->bit_left;
+ if (s->bit_left < 32)
+ s->bit_buf<<= s->bit_left;
#endif
while (s->bit_left < 32) {
/* XXX: should test end of buffer */