[FFmpeg-devel] [PATCH 2/5] avcodec/aaccoder: assert that escape case len is not causing issues

Michael Niedermayer michael at niedermayer.cc
Mon Apr 29 00:30:49 EEST 2024


Inspired by CID1465483 Unintentional integer overflow

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

diff --git a/libavcodec/aaccoder.c b/libavcodec/aaccoder.c
index 4ce54ca8867..6e5817e237b 100644
--- a/libavcodec/aaccoder.c
+++ b/libavcodec/aaccoder.c
@@ -178,6 +178,8 @@ static av_always_inline float quantize_and_encode_band_cost_template(
                         int coef = av_clip_uintp2(quant(fabsf(in[i+j]), Q, ROUNDING), 13);
                         int len = av_log2(coef);
 
+                        av_assert2(len >= 4);
+
                         put_bits(pb, len - 4 + 1, (1 << (len - 4 + 1)) - 2);
                         put_sbits(pb, len, coef);
                     }
-- 
2.43.2



More information about the ffmpeg-devel mailing list