diff mbox series

[FFmpeg-devel,1/4] avfilter/af_aresample: Cleanup on av_channel_layout_copy() failure

Message ID 20240611134422.3172010-1-michael@niedermayer.cc
State New
Headers show
Series [FFmpeg-devel,1/4] avfilter/af_aresample: Cleanup on av_channel_layout_copy() failure | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Michael Niedermayer June 11, 2024, 1:44 p.m. UTC
Fixes: CID1503078 Resource leak

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavfilter/af_aresample.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Michael Niedermayer July 7, 2024, 8:13 p.m. UTC | #1
On Tue, Jun 11, 2024 at 03:44:19PM +0200, Michael Niedermayer wrote:
> Fixes: CID1503078 Resource leak
> 
> Sponsored-by: Sovereign Tech Fund
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavfilter/af_aresample.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)

will apply patchset

[...]
diff mbox series

Patch

diff --git a/libavfilter/af_aresample.c b/libavfilter/af_aresample.c
index d6bd77beb32..8ff2fe5973f 100644
--- a/libavfilter/af_aresample.c
+++ b/libavfilter/af_aresample.c
@@ -195,8 +195,11 @@  static int filter_frame(AVFilterLink *inlink, AVFrame *insamplesref)
     av_frame_copy_props(outsamplesref, insamplesref);
     outsamplesref->format                = outlink->format;
     ret = av_channel_layout_copy(&outsamplesref->ch_layout, &outlink->ch_layout);
-    if (ret < 0)
+    if (ret < 0) {
+        av_frame_free(&outsamplesref);
+        av_frame_free(&insamplesref);
         return ret;
+    }
     outsamplesref->sample_rate           = outlink->sample_rate;
 
     if(insamplesref->pts != AV_NOPTS_VALUE) {