aboutsummaryrefslogtreecommitdiffstats
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-30 21:11:31 +0100
commit912448efc110d4249e9ec7ff7b19bd7dab0c6e50 (patch)
tree40c7e5543fa053612bd6c41afef7e84867fde22c
parent6fb7e324fee1b26f5c0ff41eab81c0a0ddd49fe5 (diff)
downloadffmpeg-912448efc110d4249e9ec7ff7b19bd7dab0c6e50.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 ff55fc8d97..5200c7d2e7 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -3763,12 +3763,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++) {
@@ -3949,6 +3943,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);
}
if (ic->pb)