avformat/mov: Fix ctts_index calculation
authorXiaohan Wang <xhwang@chromium.org>
Sat, 3 Feb 2018 01:33:56 +0000 (17:33 -0800)
committerMichael Niedermayer <michael@niedermayer.cc>
Sat, 10 Feb 2018 02:57:13 +0000 (03:57 +0100)
An index should never be equal to the count. Hence we must make sure
*ctts_index < ctts_count.

Reviewed-by: Sasi Inguva <isasi@google.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavformat/mov.c

index acfbfc5..04567fc 100644 (file)
@@ -3132,7 +3132,7 @@ static int find_prev_closest_index(AVStream *st,
             }
         }
 
-        while (*index >= 0 && (*ctts_index) >= 0) {
+        while (*index >= 0 && (*ctts_index) >= 0 && (*ctts_index) < ctts_count) {
             // Find a "key frame" with PTS <= timestamp_pts (So that we can decode B-frames correctly).
             // No need to add dts_shift to the timestamp here becase timestamp_pts has already been
             // compensated by dts_shift above.