From 8e34089e265a6b01e1e3301e8864439d26793753 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Sun, 9 Aug 2015 22:36:25 +0300 Subject: [PATCH] movenc: Check that frag_info entries exist in mov_write_sidx_tag MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes crashes with pathological cases when trying to write a sidx index (via the -movflags faststart option, in combination with fragmenting options), when no fragments actually have been written. (This is possible if the empty_moov flag isn't used, so that all actual packet data is written in the moov/mdat pair, and no moof/mdat pairs have been written.) In these pathological cases, no sidx should be written at all. Signed-off-by: Martin Storsjö --- libavformat/movenc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 158dfa8b67..a19c64b652 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -2751,6 +2751,8 @@ static int mov_write_sidx_tag(AVIOContext *pb, } } else { entries = track->nb_frag_info; + if (entries <= 0) + return 0; presentation_time = track->frag_info[0].time; }