diff mbox

[FFmpeg-devel,1/2] avformat/mov: Break out early if chunk_count is 0 in mov_build_index()

Message ID 20180515150700.4638-1-michael@niedermayer.cc
State Accepted
Commit 56e76bd0579cc7f7b28860885d9e569a39daf41b
Headers show

Commit Message

Michael Niedermayer May 15, 2018, 3:06 p.m. UTC
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 | 3 +++
 1 file changed, 3 insertions(+)
diff mbox

Patch

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 1975011741..4848a106f2 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -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;