PR #24208 opened by AYOUB NABIL BOUBAGRAT (ayoubnabil)
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24208
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24208.patch

the ir option may exceed nbirs because its static range is independent
of the configured number of impulse responses. init() only clamps
prev_selir, leaving selir able to index ctx->inputs out of range.

with the default nbirs=1, afir=ir=1 reads ctx->inputs[2] and crashes.
clamp selir like process_command() and add a fate test.



>From a90a06d4e086747753ac587692b17921bb8f366d Mon Sep 17 00:00:00 2001
From: Ayoub Nabil Boubagrat <[email protected]>
Date: Wed, 19 Aug 2026 15:36:37 +0200
Subject: [PATCH] avfilter/af_afir: clamp initial ir selection

the ir option may exceed nbirs because its static range is independent
of the configured number of impulse responses. init() only clamps
prev_selir, leaving selir able to index ctx->inputs out of range.

with the default nbirs=1, afir=ir=1 reads ctx->inputs[2] and crashes.
clamp selir like process_command() and add a fate test.

Signed-off-by: Ayoub Nabil Boubagrat 
<[email protected]>
---
 libavfilter/af_afir.c       | 4 +++-
 tests/fate/filter-audio.mak | 6 ++++++
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/libavfilter/af_afir.c b/libavfilter/af_afir.c
index 38dabc08c1..ae021b7a6f 100644
--- a/libavfilter/af_afir.c
+++ b/libavfilter/af_afir.c
@@ -663,7 +663,9 @@ static av_cold int init(AVFilterContext *ctx)
     AVFilterPad pad;
     int ret;
 
-    s->prev_selir = FFMIN(s->nb_irs - 1, s->selir);
+    /* ir is bounded by nbirs, not by its static AVOption range. */
+    s->selir      = FFMIN(s->nb_irs - 1, s->selir);
+    s->prev_selir = s->selir;
 
     pad = (AVFilterPad) {
         .name = "main",
diff --git a/tests/fate/filter-audio.mak b/tests/fate/filter-audio.mak
index 6593750805..b5c27daf1c 100644
--- a/tests/fate/filter-audio.mak
+++ b/tests/fate/filter-audio.mak
@@ -92,6 +92,12 @@ fate-filter-anequalizer: tests/data/filtergraphs/anequalizer
 fate-filter-anequalizer: SRC = $(TARGET_PATH)/tests/data/asynth-44100-2.wav
 fate-filter-anequalizer: CMD = framecrc -auto_conversion_filters -i $(SRC) 
-/filter_complex $(TARGET_PATH)/tests/data/filtergraphs/anequalizer
 
+FATE_AFILTER-$(call FILTERDEMDECENCMUX, AFIR ARESAMPLE ATRIM, WAV, PCM_S16LE, 
PCM_S16LE, WAV) += fate-filter-afir-selir
+fate-filter-afir-selir: tests/data/asynth-44100-2.wav
+fate-filter-afir-selir: SRC = $(TARGET_PATH)/tests/data/asynth-44100-2.wav
+fate-filter-afir-selir: CMD = framecrc -auto_conversion_filters -i $(SRC) -i 
$(SRC) -filter_complex "[1:a]atrim=end=0.05[ir];[0:a][ir]afir=ir=1[aout]" -map 
"[aout]" -frames:a 1
+fate-filter-afir-selir: CMP = null
+
 FATE_AFILTER-$(call FILTERDEMDECENCMUX, ASETNSAMPLES, WAV, PCM_S16LE, 
PCM_S16LE, WAV) += fate-filter-asetnsamples-pad
 fate-filter-asetnsamples-pad: tests/data/asynth-44100-2.wav
 fate-filter-asetnsamples-pad: SRC = 
$(TARGET_PATH)/tests/data/asynth-44100-2.wav
-- 
2.52.0

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

Reply via email to