diff options
author | Michael Niedermayer <michael@niedermayer.cc> | 2016-12-03 23:44:56 +0100 |
---|---|---|
committer | Michael Niedermayer <michael@niedermayer.cc> | 2016-12-04 20:25:15 +0100 |
commit | 66bf84e2c4e14f18d96fc3dc495aadc3a9e8ec75 (patch) | |
tree | 0f0bb72eaad9a5d4c876c1af529ca5df0e94484a | |
parent | 9f7eb718e9d345179283a1bbfee1d89a5e2d18bc (diff) | |
download | ffmpeg-66bf84e2c4e14f18d96fc3dc495aadc3a9e8ec75.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 4cf61d6f1b..30e9da311f 100644 --- a/libavcodec/get_bits.h +++ b/libavcodec/get_bits.h @@ -382,6 +382,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); } |