1
0
mirror of https://git.ffmpeg.org/ffmpeg.git synced 2026-10-24 02:09:03 +03:00

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 <237098474+ayoubnabil@users.noreply.github.com>
This commit is contained in:
Ayoub Nabil Boubagrat
2026-08-19 15:36:37 +02:00
committed by michaelni
parent 1a6a186b80
commit cd4fc473be
2 changed files with 9 additions and 1 deletions

View File

@@ -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",

View File

@@ -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