diff options
author | Michael Niedermayer <michael@niedermayer.cc> | 2016-12-03 23:44:56 +0100 |
---|---|---|
committer | Michael Niedermayer <michael@niedermayer.cc> | 2016-12-04 01:03:53 +0100 |
commit | a5989651f0759059f9e08906685e6cec77f518d9 (patch) | |
tree | af3fc6c0c09ef1e499b9efbfcd8d6e8a98eb7aba | |
parent | 1e512388ee986eaadb1cd960c96e64548d36f643 (diff) | |
download | ffmpeg-a5989651f0759059f9e08906685e6cec77f518d9.tar.gz |
avcodec/get_bits: Fix get_sbits_long(0)
Fixes undefined behavior
Fixes: 640889-media
Found-by: Matt Wolenetz <wolenetz@google.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit c72fa432349881d5a445cd110abf698cc94d490d)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r-- | libavcodec/get_bits.h | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/libavcodec/get_bits.h b/libavcodec/get_bits.h index 0d3db1f3cf..959e07816b 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); } |