aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2020-02-15 23:18:25 +0100
committerMichael Niedermayer <michael@niedermayer.cc>2020-05-19 17:17:35 +0200
commitc7df41ed6ba537c56a7eb90eb72f89d7496d34fc (patch)
tree520206a96cd7e2f9da68c21da17b292f0bd1d2c8
parent26e55785dda21a6399a915dcb43c3a942187e7e1 (diff)
downloadffmpeg-c7df41ed6ba537c56a7eb90eb72f89d7496d34fc.tar.gz
avformat/avidec: Avoid integer overflow in NI switch check
Fixes: signed integer overflow: 0 - -9223372036854775808 cannot be represented in type 'long' Fixes: Ticket8149 Found-by: Suhwan Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> (cherry picked from commit 347920ca2102d762e4713f101a2e75811791e2b3) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r--libavformat/avidec.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/libavformat/avidec.c b/libavformat/avidec.c
index df78925d55..2a00ac224a 100644
--- a/libavformat/avidec.c
+++ b/libavformat/avidec.c
@@ -1531,11 +1531,12 @@ resync:
if (!avi->non_interleaved && st->nb_index_entries>1 && avi->index_loaded>1) {
int64_t dts= av_rescale_q(pkt->dts, st->time_base, AV_TIME_BASE_Q);
- if (avi->dts_max - dts > 2*AV_TIME_BASE) {
+ if (avi->dts_max < dts) {
+ avi->dts_max = dts;
+ } else if (avi->dts_max - (uint64_t)dts > 2*AV_TIME_BASE) {
avi->non_interleaved= 1;
av_log(s, AV_LOG_INFO, "Switching to NI mode, due to poor interleaving\n");
- }else if (avi->dts_max < dts)
- avi->dts_max = dts;
+ }
}
return 0;