summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2019-12-26 11:53:28 +0100
committerAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2020-07-02 10:15:06 +0200
commit27c4e7d99c009977a622743afdef40fdeefcc98b (patch)
treea2e2ac28bd6efae5020ed33d5db288818ea958d4
parent7fb1978249402e3f327662a629d83de64331a9c3 (diff)
downloadffmpeg-27c4e7d99c009977a622743afdef40fdeefcc98b.tar.gz
avformat/smoothstreaming: Fix memleaks on errors
If an AVFormatContext could be allocated, but white-/blacklists couldn't be copied, the AVFormatContext would leak as it was only accessible through a local variable that goes out of scope when one goes to fail. Furthermore, in case writing a header of a submuxer failed, the options used for said call could leak. Both of these memleaks have been fixed. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> (cherry picked from commit abbb466368c51285ca27d5e3959a16a9591e9a4c) Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
-rw-r--r--libavformat/smoothstreamingenc.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/libavformat/smoothstreamingenc.c b/libavformat/smoothstreamingenc.c
index 094712af27..b0687a85f8 100644
--- a/libavformat/smoothstreamingenc.c
+++ b/libavformat/smoothstreamingenc.c
@@ -331,12 +331,11 @@ static int ism_write_header(AVFormatContext *s)
goto fail;
}
- ctx = avformat_alloc_context();
+ os->ctx = ctx = avformat_alloc_context();
if (!ctx || ff_copy_whiteblacklists(ctx, s) < 0) {
ret = AVERROR(ENOMEM);
goto fail;
}
- os->ctx = ctx;
ctx->oformat = oformat;
ctx->interrupt_callback = s->interrupt_callback;
@@ -356,12 +355,13 @@ static int ism_write_header(AVFormatContext *s)
av_dict_set_int(&opts, "ism_lookahead", c->lookahead_count, 0);
av_dict_set(&opts, "movflags", "frag_custom", 0);
- if ((ret = avformat_write_header(ctx, &opts)) < 0) {
+ ret = avformat_write_header(ctx, &opts);
+ av_dict_free(&opts);
+ if (ret < 0) {
goto fail;
}
os->ctx_inited = 1;
avio_flush(ctx->pb);
- av_dict_free(&opts);
s->streams[i]->time_base = st->time_base;
if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
c->has_video = 1;