aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2020-02-15 23:18:25 +0100
committerMichael Niedermayer <michael@niedermayer.cc>2020-04-23 21:29:01 +0200
commit60a912e005bcb26d947b312f9676e2d0a6d36844 (patch)
tree863154eea61e42a56a0b5aa92c54e6b5855f3622
parent9c151e45a8185f37f3bdbf8e567565a3e1df90e2 (diff)
downloadffmpeg-60a912e005bcb26d947b312f9676e2d0a6d36844.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 81a43632bb..26ff02bc21 100644
--- a/libavformat/avidec.c
+++ b/libavformat/avidec.c
@@ -1521,11 +1521,12 @@ FF_ENABLE_DEPRECATION_WARNINGS
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;