summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuca Barbato <lu_zero@gentoo.org>2017-04-12 01:46:30 +0200
committerMichael Niedermayer <michael@niedermayer.cc>2017-12-02 00:28:59 +0100
commit66754f0a962ebb0323269fca4ac2e93643393777 (patch)
tree28c97ffe740d2f3afbfec423029f8cccf7013b86
parenta3bb922c4da1745fb6a12adc1b4e15e97794aaa6 (diff)
downloadffmpeg-66754f0a962ebb0323269fca4ac2e93643393777.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 fa64e5c188..1a098b6d88 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -3475,12 +3475,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++) {
@@ -3596,6 +3590,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)