diff mbox series

[FFmpeg-devel] fftools/ffmpeg_opt: Fix memleak on error path

Message ID tencent_03E7FB2A921305DC700BB2A634908E26D406@qq.com
State New
Headers show
Series [FFmpeg-devel] fftools/ffmpeg_opt: Fix memleak on error path | expand

Checks

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

Commit Message

Zhao Zhili May 5, 2023, 8:44 a.m. UTC
From: Zhao Zhili <zhilizhao@tencent.com>

Fix ticket #10342.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
---
 fftools/ffmpeg_opt.c | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)
diff mbox series

Patch

diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index cf385c388e..002df84dcc 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -462,17 +462,12 @@  static int opt_map_channel(void *optctx, const char *opt, const char *arg)
     AVStream *st;
     AudioChannelMap *m;
     char *allow_unused;
-    char *mapchan;
 
     av_log(NULL, AV_LOG_WARNING,
            "The -%s option is deprecated and will be removed. "
            "It can be replaced by the 'pan' filter, or in some cases by "
            "combinations of 'channelsplit', 'channelmap', 'amerge' filters.\n", opt);
 
-    mapchan = av_strdup(arg);
-    if (!mapchan)
-        return AVERROR(ENOMEM);
-
     GROW_ARRAY(o->audio_channel_maps, o->nb_audio_channel_maps);
     m = &o->audio_channel_maps[o->nb_audio_channel_maps - 1];
 
@@ -482,7 +477,6 @@  static int opt_map_channel(void *optctx, const char *opt, const char *arg)
         m->file_idx = m->stream_idx = -1;
         if (n == 1)
             m->ofile_idx = m->ostream_idx = -1;
-        av_free(mapchan);
         return 0;
     }
 
@@ -519,8 +513,7 @@  static int opt_map_channel(void *optctx, const char *opt, const char *arg)
         exit_program(1);
     }
     /* allow trailing ? to map_channel */
-    if (allow_unused = strchr(mapchan, '?'))
-        *allow_unused = 0;
+    allow_unused = strchr(arg, '?');
     if (m->channel_idx < 0 || m->channel_idx >= st->codecpar->ch_layout.nb_channels ||
         input_files[m->file_idx]->streams[m->stream_idx]->user_set_discard == AVDISCARD_ALL) {
         if (allow_unused) {
@@ -534,7 +527,6 @@  static int opt_map_channel(void *optctx, const char *opt, const char *arg)
         }
 
     }
-    av_free(mapchan);
     return 0;
 }
 #endif