[FFmpeg-devel] [PATCH] lavfi/avfiltergraph: fix leak on error

Marvin Scholz epirat07 at gmail.com
Thu Sep 5 04:13:13 EEST 2024


Introduced in eddffbedb3443d5a4fe642de6e35b9e6a35cfda7

Fixes: CID1618897 Resource leak
---
 libavfilter/avfiltergraph.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libavfilter/avfiltergraph.c b/libavfilter/avfiltergraph.c
index c84dd3cf25..3946f04b53 100644
--- a/libavfilter/avfiltergraph.c
+++ b/libavfilter/avfiltergraph.c
@@ -372,8 +372,10 @@ static int filter_query_formats(AVFilterContext *ctx)
 
         if (ctx->nb_outputs > FF_ARRAY_ELEMS(cfg_out_stack)) {
             cfg_out_dyn = av_malloc_array(ctx->nb_outputs, sizeof(*cfg_out_dyn));
-            if (!cfg_out_dyn)
+            if (!cfg_out_dyn) {
+                av_freep(&cfg_in_dyn);
                 return AVERROR(ENOMEM);
+            }
             cfg_out = cfg_out_dyn;
         } else
             cfg_out = ctx->nb_outputs ? cfg_out_stack : NULL;

base-commit: d9f594209fb1a9c87017034f943dcb311a9d2896
-- 
2.39.3 (Apple Git-146)


More information about the ffmpeg-devel mailing list