Commit e557c9cc68 for ffmpeg
commit e557c9cc68b272fbfd57eadf86cb4d42ac674659
Author: Michael Niedermayer <michael@niedermayer.cc>
Date: Fri Nov 13 01:28:06 2026 +0100
avfilter/af_adelay: do not reallocate the delay line when it shrinks
After a failed increase av_fast_realloc() has the size 0 recorded, the
next decrease then reallocated the delay line to the smaller size
before its samples were moved.
Fixes: out of array read
Fixes: SshCIGTXgBSi
Found during the triage of a finding from the review of https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25800
Out of array read Replicated through UnModified FFmpeg with ASAN
diff --git a/libavfilter/af_adelay.c b/libavfilter/af_adelay.c
index 24e390e0bc..ebca63f67d 100644
--- a/libavfilter/af_adelay.c
+++ b/libavfilter/af_adelay.c
@@ -122,9 +122,12 @@ static int resize_samples_## name ##p(ChanDelay *d, int64_t new_delay)
return AVERROR(ENOMEM); \
} \
\
- samples = (type *) av_fast_realloc(d->samples, &d->samples_size, new_delay * sizeof(type)); \
- if (!samples) { \
- return AVERROR(ENOMEM); \
+ samples = (type *) d->samples; \
+ if (new_delay > d->delay) { \
+ samples = (type *) av_fast_realloc(d->samples, &d->samples_size, new_delay * sizeof(type)); \
+ if (!samples) { \
+ return AVERROR(ENOMEM); \
+ } \
} \
\
if (new_delay < d->delay) { \