aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuca Barbato <lu_zero@gentoo.org>2017-04-12 01:46:30 +0200
committerMichael Niedermayer <michael@niedermayer.cc>2018-01-31 22:56:14 +0100
commit907a704c9f6c4255bccdb2a45cb89d94e4520257 (patch)
treea6384f673ccb0fd6a4b97cafde585a921c8b13ac
parent35c1e95b41e9a626be39629993eb23dae2f80fd7 (diff)
downloadffmpeg-907a704c9f6c4255bccdb2a45cb89d94e4520257.tar.gz
avformat: Free the internal codec context at the end
Avoid a use after free in avformat_find_stream_info. (cherry picked from commit 9e4a5eb51b9f3b2bff0ef08e0074b7fe4893075d) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r--libavformat/utils.c7
1 files changed, 1 insertions, 6 deletions
diff --git a/libavformat/utils.c b/libavformat/utils.c
index b2a838bef4..f14174d99e 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -3435,12 +3435,6 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
}
}
- // close codecs which were opened in try_decode_frame()
- for (i = 0; i < ic->nb_streams; i++) {
- st = ic->streams[i];
- avcodec_close(st->codec);
- }
-
ff_rfps_calculate(ic);
for (i = 0; i < ic->nb_streams; i++) {
@@ -3556,6 +3550,7 @@ find_stream_info_err:
ic->streams[i]->codec->thread_count = 0;
if (st->info)
av_freep(&st->info->duration_error);
+ avcodec_close(st->codec);
av_freep(&ic->streams[i]->info);
}
if (ic->pb)