[FFmpeg-devel] [PATCH 2/2] avcodec/get_bits: always return zeros for bit_size == 0

Paul B Mahol onemda at gmail.com
Mon Oct 28 22:09:49 CET 2013


Signed-off-by: Paul B Mahol <onemda at gmail.com>
---
 libavcodec/get_bits.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavcodec/get_bits.h b/libavcodec/get_bits.h
index 640aa1f..e2a43a5 100644
--- a/libavcodec/get_bits.h
+++ b/libavcodec/get_bits.h
@@ -408,10 +408,10 @@ static inline int init_get_bits(GetBitContext *s, const uint8_t *buffer,
     int buffer_size;
     int ret = 0;
 
-    if (bit_size >= INT_MAX - 7 || bit_size < 0 || !buffer) {
+    if (bit_size >= INT_MAX - 7 || bit_size <= 0 || !buffer) {
         buffer_size = bit_size = 0;
         buffer      = (const uint8_t*)s;
-        ret         = AVERROR_INVALIDDATA;
+        ret         = bit_size ? AVERROR_INVALIDDATA : 0;
     }
 
     buffer_size = (bit_size + 7) >> 3;
-- 
1.7.11.2



More information about the ffmpeg-devel mailing list