PR #24432 opened by michaelni
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24432
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24432.patch

Found-by: Umar Pathan (Umar0x)
Signed-off-by: Umar Pathan <[email protected]>

Fixes: out of array access
Fixes: signed integer overflow: 2147482624 + 1024 cannot be represented in type 
'int'
Fixes: hHqW0dFoQwHN



>From ec581b33a85bb74aa4a9b4c130f2150095b39f7d Mon Sep 17 00:00:00 2001
From: Umar Pathan <[email protected]>
Date: Mon, 7 Sep 2026 01:06:36 +0200
Subject: [PATCH] avcodec/apac: reset bitstream_index unconditionally to avoid
 integer overflow

Found-by: Umar Pathan (Umar0x)
Signed-off-by: Umar Pathan <[email protected]>

Fixes: out of array access
Fixes: signed integer overflow: 2147482624 + 1024 cannot be represented in type 
'int'
Fixes: hHqW0dFoQwHN
---
 libavcodec/apac.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/libavcodec/apac.c b/libavcodec/apac.c
index ea3b93359d..c16d19f4d0 100644
--- a/libavcodec/apac.c
+++ b/libavcodec/apac.c
@@ -143,8 +143,9 @@ static int apac_decode(AVCodecContext *avctx, AVFrame 
*frame,
     if ((int64_t)s->bitstream_size + buf_size > INT_MAX / (16 * 8))
         return AVERROR_INVALIDDATA;
 
-    if (s->bitstream_index > 0 && s->bitstream_size > 0) {
-        memmove(s->bitstream, &s->bitstream[s->bitstream_index], 
s->bitstream_size);
+    if (s->bitstream_index > 0) {
+        if (s->bitstream_size > 0)
+            memmove(s->bitstream, &s->bitstream[s->bitstream_index], 
s->bitstream_size);
         s->bitstream_index = 0;
     }
 
-- 
2.52.0

_______________________________________________
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to