summaryrefslogtreecommitdiff
path: root/libavformat/movenc.c
diff options
context:
space:
mode:
authorMartin Storsjö <martin@martin.st>2015-08-09 22:36:25 +0300
committerMartin Storsjö <martin@martin.st>2015-08-10 09:46:03 +0300
commit8e34089e265a6b01e1e3301e8864439d26793753 (patch)
tree6236ea08ef82daae9050b95182613d752276b163 /libavformat/movenc.c
parent1542ec96389f32e5081c6c607e4b6f5e257ccdf2 (diff)
movenc: Check that frag_info entries exist in mov_write_sidx_tag
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ö <martin@martin.st>
Diffstat (limited to 'libavformat/movenc.c')
-rw-r--r--libavformat/movenc.c2
1 files changed, 2 insertions, 0 deletions
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;
}