diff options
author | Luca Barbato <lu_zero@gentoo.org> | 2017-04-12 01:46:30 +0200 |
---|---|---|
committer | Michael Niedermayer <michael@niedermayer.cc> | 2017-12-07 23:38:06 +0100 |
commit | 78b8aeee585b40c251bcf5686dcb635378ba3a44 (patch) | |
tree | ee8ace08878f35bd9ffc09abf411dce627c497e1 | |
parent | 66e65e0a686a875fc4693e332bba6a2a221fe946 (diff) | |
download | ffmpeg-78b8aeee585b40c251bcf5686dcb635378ba3a44.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 1a7996c4fd..881438a504 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -3882,12 +3882,6 @@ FF_ENABLE_DEPRECATION_WARNINGS } } - // close codecs which were opened in try_decode_frame() - for (i = 0; i < ic->nb_streams; i++) { - st = ic->streams[i]; - avcodec_close(st->internal->avctx); - } - ff_rfps_calculate(ic); for (i = 0; i < ic->nb_streams; i++) { @@ -4078,6 +4072,7 @@ find_stream_info_err: st = ic->streams[i]; if (st->info) av_freep(&st->info->duration_error); + avcodec_close(ic->streams[i]->internal->avctx); av_freep(&ic->streams[i]->info); av_bsf_free(&ic->streams[i]->internal->extract_extradata.bsf); av_packet_free(&ic->streams[i]->internal->extract_extradata.pkt); |