aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2016-12-03 23:44:56 +0100
committerMichael Niedermayer <michael@niedermayer.cc>2017-08-23 13:15:16 +0200
commit2e7800778c8aadb3362797caca4b6daa8c6bf3a0 (patch)
tree232a4aaf03467865d94f1eaf985896e8b261f91a
parenta9479bbc5711de0d33675b614372e9d3647e1aa5 (diff)
downloadffmpeg-2e7800778c8aadb3362797caca4b6daa8c6bf3a0.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.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/libavcodec/get_bits.h b/libavcodec/get_bits.h
index b9dec4fe35..8a40aeeae7 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);
}