diff mbox

[FFmpeg-devel,2/2] avformat/utils: Fix long overflow in compute_pkt_fields()

Message ID 20181012014021.9579-2-michael@niedermayer.cc
State New
Headers show

Commit Message

Michael Niedermayer Oct. 12, 2018, 1:40 a.m. UTC
From: Thomas Guilbert <tguilbert@chromium.org>

If ever we have a negative last_IP_duration, we can end up with a long
overflow. This makes sure we use pkt->duration instead of
last_IP_duration if last_IP_duration is negative.

Fixes: compute_pkt_usan
---
 libavformat/utils.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox

Patch

diff --git a/libavformat/utils.c b/libavformat/utils.c
index fa3699daef..2c965a7fb2 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -1352,7 +1352,7 @@  static void compute_pkt_fields(AVFormatContext *s, AVStream *st,
 
             /* This is tricky: the dts must be incremented by the duration
              * of the frame we are displaying, i.e. the last I- or P-frame. */
-            if (st->last_IP_duration == 0)
+            if (st->last_IP_duration <= 0)
                 st->last_IP_duration = pkt->duration;
             if (pkt->dts != AV_NOPTS_VALUE)
                 st->cur_dts = pkt->dts + st->last_IP_duration;