aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2022-03-14 12:30:31 +0100
committerAnton Khirnov <anton@khirnov.net>2024-01-20 10:23:24 +0100
commit8aed3911fc454e79697e183660bf30d31334a64b (patch)
tree7fd9f4924dd03faec58f5324a8b92f3886aacc3b
parentfcddd233fef4075a884a87585f1187e0d52af3d5 (diff)
downloadffmpeg-8aed3911fc454e79697e183660bf30d31334a64b.tar.gz
fftools/ffmpeg: make attachment filenames dynamically allocated
Do not store the supplied arg pointer directly. While that is valid for now, it will become ephemeral in the future commits.
-rw-r--r--fftools/ffmpeg_opt.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index ea995f2b5f..563f443bd8 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -124,6 +124,9 @@ static void uninit_options(OptionsContext *o)
#if FFMPEG_OPT_MAP_CHANNEL
av_freep(&o->audio_channel_maps);
#endif
+
+ for (i = 0; i < o->nb_attachments; i++)
+ av_freep(&o->attachments[i]);
av_freep(&o->attachments);
av_dict_free(&o->streamid);
@@ -494,7 +497,10 @@ static int opt_attach(void *optctx, const char *opt, const char *arg)
if (ret < 0)
return ret;
- o->attachments[o->nb_attachments - 1] = arg;
+ o->attachments[o->nb_attachments - 1] = av_strdup(arg);
+ if (!o->attachments[o->nb_attachments - 1])
+ return AVERROR(ENOMEM);
+
return 0;
}