PR #26136 opened by Marvin Scholz (ePirat)
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/26136
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/26136.patch

(cherry picked from commit 974a75798a53736067008d3dd4cad97d167ca0db)
Signed-off-by: Marvin Scholz <[email protected]>


>From 2f5e4b9521db2ae309e5c2dd6e409fab27e1ad99 Mon Sep 17 00:00:00 2001
From: Zhao Zhili <[email protected]>
Date: Mon, 15 Jun 2026 22:23:45 +0800
Subject: [PATCH] avformat/mov_chan: free temporary layout on error paths

(cherry picked from commit 974a75798a53736067008d3dd4cad97d167ca0db)
Signed-off-by: Marvin Scholz <[email protected]>
---
 libavformat/mov_chan.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/libavformat/mov_chan.c b/libavformat/mov_chan.c
index 82a4bd07ac4..dd1dfa752da 100644
--- a/libavformat/mov_chan.c
+++ b/libavformat/mov_chan.c
@@ -396,8 +396,10 @@ static int mov_get_channel_layout(AVChannelLayout 
*ch_layout, uint32_t tag, uint
         }
 
         ret = av_channel_layout_retype(&tmp, 0, 
AV_CHANNEL_LAYOUT_RETYPE_FLAG_CANONICAL);
-        if (ret < 0)
+        if (ret < 0) {
+            av_channel_layout_uninit(&tmp);
             return ret;
+        }
 
         av_channel_layout_uninit(ch_layout);
         *ch_layout = tmp;
@@ -577,6 +579,7 @@ int ff_mov_read_chan(AVFormatContext *s, AVIOContext *pb, 
AVStream *st,
             if (pb->eof_reached) {
                 av_log(s, AV_LOG_ERROR,
                        "reached EOF while reading channel layout\n");
+                av_channel_layout_uninit(&tmp);
                 return AVERROR_INVALIDDATA;
             }
             label     = avio_rb32(pb);          // mChannelLabel
@@ -589,8 +592,10 @@ int ff_mov_read_chan(AVFormatContext *s, AVIOContext *pb, 
AVStream *st,
         }
 
         ret = av_channel_layout_retype(&tmp, 0, 
AV_CHANNEL_LAYOUT_RETYPE_FLAG_CANONICAL);
-        if (ret < 0)
+        if (ret < 0) {
+            av_channel_layout_uninit(&tmp);
             goto out;
+        }
 
        av_channel_layout_uninit(ch_layout);
        *ch_layout = tmp;
@@ -773,8 +778,10 @@ int ff_mov_read_chnl(AVFormatContext *s, AVIOContext *pb, 
AVStream *st)
             }
 
             ret = av_channel_layout_retype(&tmp, 0, 
AV_CHANNEL_LAYOUT_RETYPE_FLAG_CANONICAL);
-            if (ret < 0)
+            if (ret < 0) {
+                av_channel_layout_uninit(&tmp);
                 return ret;
+            }
 
             av_channel_layout_uninit(ch_layout);
             *ch_layout = tmp;
-- 
2.54.0

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

Reply via email to