[FFmpeg-devel] [PATCH] avformat/mov: fix return code for trun box with no sample entries

Gyan ffmpeg at gyani.pro
Sat Jul 20 21:32:31 EEST 2019


Affected files can now be demuxed. Verified with John Stebbins. FATE passes.

Gyan
-------------- next part --------------
From 48175cd745f8abd0546487907c4596550e3c73bf Mon Sep 17 00:00:00 2001
From: Gyan Doshi <ffmpeg at gyani.pro>
Date: Sat, 20 Jul 2019 23:44:14 +0530
Subject: [PATCH] avformat/mov: fix return code for trun box with no sample
 entries

A value of zero for sample_count in trun box is not
prohibited by 14496-12 section 8.8.8. 4a9d32baca
disallowed this which led the demuxer to error out
when reading the header of valid files.
---
 libavformat/mov.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 327a25bbdf..ea26d78d91 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -4776,13 +4776,14 @@ static int mov_read_trun(MOVContext *c, AVIOContext *pb, MOVAtom atom)
     distance = 0;
     av_log(c->fc, AV_LOG_TRACE, "first sample flags 0x%x\n", first_sample_flags);
 
+    if (entries == 0)
+        return 0;
+
     // realloc space for new index entries
     if((uint64_t)st->nb_index_entries + entries >= UINT_MAX / sizeof(AVIndexEntry)) {
         entries = UINT_MAX / sizeof(AVIndexEntry) - st->nb_index_entries;
         av_log(c->fc, AV_LOG_ERROR, "Failed to add index entry\n");
     }
-    if (entries <= 0)
-        return -1;
 
     requested_size = (st->nb_index_entries + entries) * sizeof(AVIndexEntry);
     new_entries = av_fast_realloc(st->index_entries,
-- 
2.22.0


More information about the ffmpeg-devel mailing list