diff mbox series

[FFmpeg-devel,13/25] avformat/utils: Don't initialize AVStreamInternal.info multiple times

Message ID AM7PR03MB6660121B33C46F93F7B97AB08FC89@AM7PR03MB6660.eurprd03.prod.outlook.com
State Accepted
Commit 10646d30a3637d1bd0a563c025caea31f81b27d3
Headers show
Series [FFmpeg-devel,01/25] avformat/matroskadec: Fix heap-buffer overflow upon gigantic timestamps | expand


Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished
andriy/configureppc warning Failed to apply patch

Commit Message

Andreas Rheinhardt Aug. 27, 2021, 2:27 p.m. UTC
It has been allocated and initialized in avformat_find_stream_info()
until fd0368e7ca35e2feaf7960564e61a76655c4d1f6 when the structure
was moved to AVStreamInternal and its allocation to avformat_new_stream.
In order to also initialize the struct for new streams that only get
created during avformat_find_stream_info() said the initialization has
been added to avformat_new_stream() later. Due to the Libav-FFmpeg split
this has been done twice: In 4cda8aa1c5bc58f8a7f53a21a19b03e7379bbcdc
and in 30c26c2442e4e44ac5a763c23c4b0fdd9921a7f5. The initialization in
avformat_find_stream_info() has not been removed at all despite being
redundant. This commit removes it and the duplicated initialization in

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
a) avformat_find_stream_info() frees this info field; this implies
that calling it again leads to crashes. Moreover, I am not even certain
that the calls to ff_rfps_add_frame() that the mov demuxer performs
are safe (i.e. happen before any call to avformat_find_stream_info()).
b) That info structure should have a proper type to simplify the many

 libavformat/utils.c | 9 ---------
 1 file changed, 9 deletions(-)
diff mbox series


diff --git a/libavformat/utils.c b/libavformat/utils.c
index 79fa9382cf..8cbe2a0278 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -3624,14 +3624,6 @@  int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
-    for (i = 0; i < ic->nb_streams; i++) {
-        ic->streams[i]->internal->info->last_dts = AV_NOPTS_VALUE;
-        ic->streams[i]->internal->info->fps_first_dts = AV_NOPTS_VALUE;
-        ic->streams[i]->internal->info->fps_last_dts  = AV_NOPTS_VALUE;
-    }
     read_size = 0;
     for (;;) {
         const AVPacket *pkt;
@@ -4379,7 +4371,6 @@  AVStream *avformat_new_stream(AVFormatContext *s, const AVCodec *c)
     st->internal->info = av_mallocz(sizeof(*st->internal->info));
     if (!st->internal->info)
         goto fail;
-    st->internal->info->last_dts = AV_NOPTS_VALUE;
     st->codecpar = avcodec_parameters_alloc();
     if (!st->codecpar)