[FFmpeg-devel] [PATCH] fftools/ffmpeg_opt: Fix memleak on error path
Zhao Zhili
quinkblack at foxmail.com
Fri May 5 11:44:22 EEST 2023
From: Zhao Zhili <zhilizhao at tencent.com>
Fix ticket #10342.
Signed-off-by: Zhao Zhili <zhilizhao at tencent.com>
---
fftools/ffmpeg_opt.c | 10 +---------
1 file changed, 1 insertion(+), 9 deletions(-)
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
--
2.25.1
More information about the ffmpeg-devel
mailing list