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

When av_mallocz() fails after av_realloc_array() succeeds,
the reallocated fdec pointer is leaked.


>From c55db006f51e6b951b7ddee1faf5b22f20e299a8 Mon Sep 17 00:00:00 2001
From: tangsha <[email protected]>
Date: Wed, 20 May 2026 15:02:47 +0800
Subject: [PATCH] avcodec/wavpack: Fix memory leak in wv_alloc_frame_context()

When av_mallocz() fails after av_realloc_array() succeeds,
the reallocated fdec pointer is leaked.
---
 libavcodec/wavpack.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/libavcodec/wavpack.c b/libavcodec/wavpack.c
index 341315373f..0dd9f4258f 100644
--- a/libavcodec/wavpack.c
+++ b/libavcodec/wavpack.c
@@ -980,7 +980,11 @@ static av_cold int wv_alloc_frame_context(WavpackContext 
*c)
 
     c->fdec[c->fdec_num] = av_mallocz(sizeof(**c->fdec));
     if (!c->fdec[c->fdec_num])
+    {
+        av_free(&c->fdec);
+        c->fdec = NULL;
         return -1;
+    }
     c->fdec_num++;
     c->fdec[c->fdec_num - 1]->avctx = c->avctx;
 
-- 
2.52.0

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

Reply via email to