Commit 8aeab0db authored by Andreas Rheinhardt's avatar Andreas Rheinhardt Committed by Michael Niedermayer

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: 's avatarAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Reviewed-by: 's avatar"Jeyapal, Karthick" <kjeyapal@akamai.com>
Signed-off-by: 's avatarMichael Niedermayer <michael@niedermayer.cc>
parent ad18f69b
......@@ -1225,10 +1225,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)
......@@ -1261,10 +1257,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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment