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

Check the return value of ac_get_freq() in amdl_decode_int() and propagate 
failure instead of using an uninitialized val when the arithmetic coder cannot 
provide a frequency. This prevents uninitialized stack data from influencing 
decoded symbol selection.


>From fa1b079e0416a7a6c35709696a0ff1d576dfaf1b Mon Sep 17 00:00:00 2001
From: Richard Desmarais <[email protected]>
Date: Sun, 15 Nov 2026 17:14:47 -0500
Subject: [PATCH] Fix uninitialized value in RKA amdl_decode_int

---
 libavcodec/rka.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/libavcodec/rka.c b/libavcodec/rka.c
index 975ff6dedf2..9dc482d5834 100644
--- a/libavcodec/rka.c
+++ b/libavcodec/rka.c
@@ -430,7 +430,8 @@ static int amdl_decode_int(AdaptiveModel *am, ACoder *ac, 
unsigned *dst, unsigne
             for (int j = size; j > 0; j &= (j - 1) )
                 freq += am->prob[0][j];
         }
-        ac_get_freq(ac, freq, &freq);
+        if (ac_get_freq(ac, freq, &freq) < 0)
+            return -1;
         size2 = am->buf_size >> 1;
         val = am->prob[0][0];
         if (freq >= val) {
@@ -460,14 +461,16 @@ static int amdl_decode_int(AdaptiveModel *am, ACoder *ac, 
unsigned *dst, unsigne
     }
     am->aprob1++;
     if (size == am->buf_size - 1) {
-        ac_get_freq(ac, am->buf_size - am->total, &val);
+        if (ac_get_freq(ac, am->buf_size - am->total, &val) < 0)
+            return -1;
     } else {
         freq = 1;
         for (dst[0] = 0; dst[0] < size; dst[0]++) {
             if (!am->prob[1][dst[0]])
                 freq++;
         }
-        ac_get_freq(ac, freq, &val);
+        if (ac_get_freq(ac, freq, &val) < 0)
+            return -1;
     }
     freq = 0;
     dst[0] = 0;
-- 
2.54.0

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

Reply via email to