[FFmpeg-cvslog] avcodec/get_bits: Fix get_sbits_long(0)

Michael Niedermayer git at videolan.org
Sun Dec 4 02:58:12 EET 2016


ffmpeg | branch: release/2.8 | Michael Niedermayer <michael at niedermayer.cc> | Sat Dec  3 23:44:56 2016 +0100| [a5989651f0759059f9e08906685e6cec77f518d9] | committer: Michael Niedermayer

avcodec/get_bits: Fix get_sbits_long(0)

Fixes undefined behavior
Fixes: 640889-media

Found-by: Matt Wolenetz <wolenetz at google.com>
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
(cherry picked from commit c72fa432349881d5a445cd110abf698cc94d490d)
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a5989651f0759059f9e08906685e6cec77f518d9
---

 libavcodec/get_bits.h | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/libavcodec/get_bits.h b/libavcodec/get_bits.h
index 0d3db1f..959e078 100644
--- a/libavcodec/get_bits.h
+++ b/libavcodec/get_bits.h
@@ -374,6 +374,10 @@ static inline uint64_t get_bits64(GetBitContext *s, int n)
  */
 static inline int get_sbits_long(GetBitContext *s, int n)
 {
+    // sign_extend(x, 0) is undefined
+    if (!n)
+        return 0;
+
     return sign_extend(get_bits_long(s, n), n);
 }
 



More information about the ffmpeg-cvslog mailing list