[FFmpeg-cvslog] avformat/avidec: Avoid integer overflow in NI switch check
Michael Niedermayer
git at videolan.org
Fri Apr 24 02:13:54 EEST 2020
ffmpeg | branch: release/2.8 | Michael Niedermayer <michael at niedermayer.cc> | Sat Feb 15 23:18:25 2020 +0100| [60a912e005bcb26d947b312f9676e2d0a6d36844] | committer: Michael Niedermayer
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 at gmail.com>
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
(cherry picked from commit 347920ca2102d762e4713f101a2e75811791e2b3)
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=60a912e005bcb26d947b312f9676e2d0a6d36844
---
libavformat/avidec.c | 7 ++++---
1 file 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;
More information about the ffmpeg-cvslog
mailing list