[PR] avfilter/af_adeclick: free transform contexts and buffers on error (PR #23646)

michaelni via ffmpeg-devel <[email protected]>
Newsgroups gmane.comp.video.ffmpeg.devel
Message-ID <178276632193.59.9489020846049091055@29965ddac10e>
PR #23646 opened by michaelni
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/23646
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/23646.patch

Found-by: Ao Xijie
Signed-off-by: Michael Niedermayer <[email protected]>



>From 7d6ba3101005f87a51ecdf41a76d433519465d73 Mon Sep 17 00:00:00 2001
From: Michael Niedermayer <[email protected]>
Date: Mon, 29 Jun 2026 01:35:05 +0200
Subject: [PATCH] avfilter/af_adeclick: free transform contexts and buffers on
 error

Found-by: Ao Xijie
Signed-off-by: Michael Niedermayer <[email protected]>
---
 libavfilter/af_adeclick.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/libavfilter/af_adeclick.c b/libavfilter/af_adeclick.c
index 043435b186..198e7fab63 100644
--- a/libavfilter/af_adeclick.c
+++ b/libavfilter/af_adeclick.c
@@ -130,8 +130,8 @@ static int config_input(AVFilterLink *inlink)
         return AVERROR(ENOMEM);
 
     {
-        double *tx_in[2], *tx_out[2];
-        AVTXContext *tx, *itx;
+        double *tx_in[2] = { NULL }, *tx_out[2] = { NULL };
+        AVTXContext *tx = NULL, *itx = NULL;
         av_tx_fn tx_fn, itx_fn;
         int ret, tx_size;
         double scale;
@@ -141,19 +141,21 @@ static int config_input(AVFilterLink *inlink)
         scale = 1.0;
         ret = av_tx_init(&tx, &tx_fn, AV_TX_DOUBLE_RDFT, 0, tx_size, &scale, 0);
         if (ret < 0)
-            return ret;
+            goto tx_end;
 
         scale = 1.0 / tx_size;
         ret = av_tx_init(&itx, &itx_fn, AV_TX_DOUBLE_RDFT, 1, tx_size, &scale, 0);
         if (ret < 0)
-            return ret;
+            goto tx_end;
 
         tx_in[0]  = av_calloc(tx_size + 2, sizeof(*tx_in[0]));
         tx_in[1]  = av_calloc(tx_size + 2, sizeof(*tx_in[1]));
         tx_out[0] = av_calloc(tx_size + 2, sizeof(*tx_out[0]));
         tx_out[1] = av_calloc(tx_size + 2, sizeof(*tx_out[1]));
-        if (!tx_in[0] || !tx_in[1] || !tx_out[0] || !tx_out[1])
-            return AVERROR(ENOMEM);
+        if (!tx_in[0] || !tx_in[1] || !tx_out[0] || !tx_out[1]) {
+            ret = AVERROR(ENOMEM);
+            goto tx_end;
+        }
 
         for (int n = 0; n < s->window_size - s->hop_size; n++)
             tx_in[0][n] = 1.0;
@@ -180,6 +182,7 @@ static int config_input(AVFilterLink *inlink)
         for (int n = 0; n < s->window_size; n++)
             s->window_func_lut[n] = tx_out[0][n] * scale;
 
+tx_end:
         av_tx_uninit(&tx);
         av_tx_uninit(&itx);
 
@@ -187,6 +190,9 @@ static int config_input(AVFilterLink *inlink)
         av_freep(&tx_in[1]);
         av_freep(&tx_out[0]);
         av_freep(&tx_out[1]);
+
+        if (ret < 0)
+            return ret;
     }
 
     av_frame_free(&s->in);
-- 
2.52.0

_______________________________________________
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.