[FFmpeg-devel] [PATCH 05/15] avcodec/golomb: Assert that k is in the supported range for get_ur/sr_golomb()

Michael Niedermayer michael at niedermayer.cc
Fri Jul 5 03:21:46 EEST 2024


Found by code review related to CID1604563 Overflowed return value

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
---
 libavcodec/golomb.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavcodec/golomb.h b/libavcodec/golomb.h
index 9f60fe03976..742334978d5 100644
--- a/libavcodec/golomb.h
+++ b/libavcodec/golomb.h
@@ -402,6 +402,7 @@ static inline int get_ur_golomb(GetBitContext *gb, int k, int limit,
     log = av_log2(buf);
 
     if (log > 31 - limit) {
+        av_assert2(log >= k);
         buf >>= log - k;
         buf  += (30U - log) << k;
         LAST_SKIP_BITS(re, gb, 32 + k - log);
-- 
2.45.2



More information about the ffmpeg-devel mailing list