diff options
author | Andreas Rheinhardt <andreas.rheinhardt@gmail.com> | 2020-01-07 14:55:46 +0100 |
---|---|---|
committer | Andreas Rheinhardt <andreas.rheinhardt@gmail.com> | 2020-05-20 02:36:02 +0200 |
commit | efea91321e5eb702e8a37bf29cbd84aa2ad81acb (patch) | |
tree | 377bb07d2a8d76076c32b355ee0fde9e0e5adfa5 /libavformat/dashenc.c | |
parent | 9dad33fcaede598cc61860bb82699d73f0d2960b (diff) | |
download | ffmpeg-efea91321e5eb702e8a37bf29cbd84aa2ad81acb.tar.gz |
avformat/dashenc: Fix leak of AVFormatContext on error
The Dash muxer uses submuxers and when one such submuxer has been allocated,
it is initially only stored in a temporary variable. Therefore it leaks
if an error happens between the allocation and storing it permanently.
This commit changes this.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Reviewed-by: "Jeyapal, Karthick" <kjeyapal@akamai.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 8aeab0dbc159d65a20bb4cc89c2524b482fd867a)
Diffstat (limited to 'libavformat/dashenc.c')
-rw-r--r-- | libavformat/dashenc.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c index 24d43c34ea..f0e45da89a 100644 --- a/libavformat/dashenc.c +++ b/libavformat/dashenc.c @@ -1207,10 +1207,6 @@ static int dash_init(AVFormatContext *s) dict_copy_entry(&as->metadata, s->streams[i]->metadata, "language"); dict_copy_entry(&as->metadata, s->streams[i]->metadata, "role"); - ctx = avformat_alloc_context(); - if (!ctx) - return AVERROR(ENOMEM); - if (c->init_seg_name) { os->init_seg_name = av_strireplace(c->init_seg_name, "$ext$", os->extension_name); if (!os->init_seg_name) @@ -1243,10 +1239,13 @@ static int dash_init(AVFormatContext *s) } } + os->ctx = ctx = avformat_alloc_context(); + if (!ctx) + return AVERROR(ENOMEM); + ctx->oformat = av_guess_format(os->format_name, NULL, NULL); if (!ctx->oformat) return AVERROR_MUXER_NOT_FOUND; - os->ctx = ctx; ctx->interrupt_callback = s->interrupt_callback; ctx->opaque = s->opaque; ctx->io_close = s->io_close; |