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

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



>From c858203350334dc03b894d997733d1b63763b69b Mon Sep 17 00:00:00 2001
From: Michael Niedermayer <[email protected]>
Date: Fri, 6 Nov 2026 16:04:04 +0100
Subject: [PATCH] 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
---
 libavfilter/af_anlmdn.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/libavfilter/af_anlmdn.c b/libavfilter/af_anlmdn.c
index 366e63cb09d..11da25081a1 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)
-- 
2.54.0

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

Reply via email to