avformat/mov: Break out early if chunk_count is 0 in mov_build_index()
authorMichael Niedermayer <michael@niedermayer.cc>
Tue, 15 May 2018 15:06:59 +0000 (17:06 +0200)
committerMichael Niedermayer <michael@niedermayer.cc>
Sun, 20 May 2018 23:38:56 +0000 (01:38 +0200)
Without this some operations might overflow (undefined behavior)
even though the index adding loop would never execute

No testcase known

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavformat/mov.c

index 1975011..4848a10 100644 (file)
@@ -3900,6 +3900,9 @@ static void mov_build_index(MOVContext *mov, AVStream *st)
     } else {
         unsigned chunk_samples, total = 0;
 
+        if (!sc->chunk_count)
+            return;
+
         // compute total chunk count
         for (i = 0; i < sc->stsc_count; i++) {
             unsigned count, chunk_count;