diff options
author | Luca Barbato <lu_zero@gentoo.org> | 2017-04-12 01:46:30 +0200 |
---|---|---|
committer | Michael Niedermayer <michael@niedermayer.cc> | 2017-11-09 02:11:29 +0100 |
commit | 805923f2303e68e3fffdbeba5ddded50f8f4315c (patch) | |
tree | 2ba9be0cf11046fec141d03ea6fb97b15506cf5a | |
parent | 80b6f5d1dc7e2f741119b0c545793c0df459a9b3 (diff) | |
download | ffmpeg-805923f2303e68e3fffdbeba5ddded50f8f4315c.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.c | 7 |
1 files changed, 1 insertions, 6 deletions
diff --git a/libavformat/utils.c b/libavformat/utils.c index f6d82d2927..52216e314f 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -3273,12 +3273,6 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options) } av_opt_set(ic, "skip_clear", "0", AV_OPT_SEARCH_CHILDREN); - // 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++) { @@ -3387,6 +3381,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) |