Commit dee3793c78 for ffmpeg
commit dee3793c78c631dfb34af08b072e24d572c42aa4
Author: Michael Niedermayer <michael@niedermayer.cc>
Date: Fri Nov 6 16:04:04 2026 +0100
avfilter/af_anlmdn: apply new parameters before taking the next frame
Queued commands are processed after
ff_inlink_consume_samples() took a frame of H samples. A command
reducing H then made filter_channel() clear the window with a negative
size. Apply new parameters at the start of activate() instead.
Fixes: jFEHZBDW72eB
Found during review of the fix for the security report uQUc1sfqWcj8
Negative size memset Replicated through UnModified FFmpeg with ASAN
diff --git a/libavfilter/af_anlmdn.c b/libavfilter/af_anlmdn.c
index 366e63cb09..11da25081a 100644
--- a/libavfilter/af_anlmdn.c
+++ b/libavfilter/af_anlmdn.c
@@ -47,6 +47,7 @@ typedef struct AudioNLMeansContext {
int S;
int N;
int H;
+ int reconfigure;
AVFrame *in;
AVFrame *cache;
@@ -302,6 +303,13 @@ static int activate(AVFilterContext *ctx)
FF_FILTER_FORWARD_STATUS_BACK(outlink, inlink);
+ if (s->reconfigure) {
+ s->reconfigure = 0;
+ ret = config_filter(ctx);
+ if (ret < 0)
+ return ret;
+ }
+
ret = ff_inlink_consume_samples(inlink, s->H, s->H, &in);
if (ret < 0)
return ret;
@@ -324,13 +332,15 @@ static int activate(AVFilterContext *ctx)
static int process_command(AVFilterContext *ctx, const char *cmd, const char *args,
char *res, int res_len, int flags)
{
+ AudioNLMeansContext *s = ctx->priv;
int ret;
ret = ff_filter_process_command(ctx, cmd, args, res, res_len, flags);
if (ret < 0)
return ret;
- return config_filter(ctx);
+ s->reconfigure = 1;
+ return 0;
}
static av_cold void uninit(AVFilterContext *ctx)