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

note that the spec actually disallows the 0 case too but we are
a little lenient here so the full 24bit twos-complement range can be handled

Signed-off-by: Michael Niedermayer <[email protected]>


>From 7b9130bf82a6bc7fd2316dc52a330f80b73db392 Mon Sep 17 00:00:00 2001
From: Michael Niedermayer <[email protected]>
Date: Wed, 25 Mar 2026 01:25:40 +0100
Subject: [PATCH] avcodec/alsdec: do not set nbits invalidly

note that the spec actually disallows the 0 case too but we are
a little lenient here so the full 24bit twos-complement range can be handled

Signed-off-by: Michael Niedermayer <[email protected]>
---
 libavcodec/alsdec.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/libavcodec/alsdec.c b/libavcodec/alsdec.c
index e91ff57b03..9f2e591e6c 100644
--- a/libavcodec/alsdec.c
+++ b/libavcodec/alsdec.c
@@ -1560,7 +1560,10 @@ static int read_diff_float_data(ALSDecContext *ctx, 
unsigned int ra_frame) {
                 if (ctx->raw_samples[c][i] != 0) {
                     //The following logic is taken from Table 14.45 and 14.46 
from the ISO spec
                     if (av_cmp_sf_ieee754(acf[c], FLOAT_1)) {
-                        nbits[i] = 23 - 
av_log2(FFABSU(ctx->raw_samples[c][i]));
+                        int nbit = av_log2(FFABSU(ctx->raw_samples[c][i]));
+                        if (nbit > 23)
+                            return AVERROR_INVALIDDATA;
+                        nbits[i] = 23 - nbit;
                     } else {
                         nbits[i] = 23;
                     }
-- 
2.52.0

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

Reply via email to