avformat/mov: Move +1 in check to avoid hypothetical overflow in add_ctts_entry()
authorMichael Niedermayer <michael@niedermayer.cc>
Sat, 3 Feb 2018 20:36:22 +0000 (21:36 +0100)
committerMichael Niedermayer <michael@niedermayer.cc>
Mon, 26 Mar 2018 00:16:48 +0000 (02:16 +0200)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavformat/mov.c

index 3312678..cb6f3a4 100644 (file)
@@ -3256,7 +3256,7 @@ static int64_t add_ctts_entry(MOVStts** ctts_data, unsigned int* ctts_count, uns
         FFMAX(min_size_needed, 2 * (*allocated_size)) :
         min_size_needed;
 
-    if((unsigned)(*ctts_count) + 1 >= UINT_MAX / sizeof(MOVStts))
+    if((unsigned)(*ctts_count) >= UINT_MAX / sizeof(MOVStts) - 1)
         return -1;
 
     ctts_buf_new = av_fast_realloc(*ctts_data, allocated_size, requested_size);