mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-28 20:53:54 +02:00
avformat: Free the internal codec context at the end
Avoid a use after free in avformat_find_stream_info.
(cherry picked from commit 9e4a5eb51b
)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
parent
a3bb922c4d
commit
66754f0a96
@ -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);
|
ff_rfps_calculate(ic);
|
||||||
|
|
||||||
for (i = 0; i < ic->nb_streams; i++) {
|
for (i = 0; i < ic->nb_streams; i++) {
|
||||||
@ -3596,6 +3590,7 @@ find_stream_info_err:
|
|||||||
ic->streams[i]->codec->thread_count = 0;
|
ic->streams[i]->codec->thread_count = 0;
|
||||||
if (st->info)
|
if (st->info)
|
||||||
av_freep(&st->info->duration_error);
|
av_freep(&st->info->duration_error);
|
||||||
|
avcodec_close(st->codec);
|
||||||
av_freep(&ic->streams[i]->info);
|
av_freep(&ic->streams[i]->info);
|
||||||
}
|
}
|
||||||
if (ic->pb)
|
if (ic->pb)
|
||||||
|
Loading…
Reference in New Issue
Block a user