aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2018-10-12 20:55:25 +0200
committerMichael Niedermayer <michael@niedermayer.cc>2018-11-01 00:52:46 +0100
commita1f4fe165a4063433d1f0472b3ed5dbf15130b96 (patch)
treed10c2d09856102c5ecadffe068c50a4b08da2029
parent1e59d05e48f9e12aa50a3ad89d6a78c281997a6f (diff)
downloadffmpeg-a1f4fe165a4063433d1f0472b3ed5dbf15130b96.tar.gz
avformat/utils: Never store negative values in last_IP_duration
Fixes: integer overflow compute_pkt_fields() Fixes: compute_pkt_usan Reported-by: Thomas Guilbert <tguilbert@chromium.org> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> (cherry picked from commit 079d1a7175c4b881631a7e7f449c4c13b761cdeb) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r--libavformat/utils.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 0f6b0f6e53..362497d284 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -1311,7 +1311,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 && (uint64_t)pkt->duration <= INT32_MAX)
st->last_IP_duration = pkt->duration;
if (pkt->dts != AV_NOPTS_VALUE)
st->cur_dts = pkt->dts + st->last_IP_duration;
@@ -1323,7 +1323,8 @@ static void compute_pkt_fields(AVFormatContext *s, AVStream *st,
next_pts != AV_NOPTS_VALUE)
pkt->pts = next_dts;
- st->last_IP_duration = pkt->duration;
+ if ((uint64_t)pkt->duration <= INT32_MAX)
+ st->last_IP_duration = pkt->duration;
st->last_IP_pts = pkt->pts;
/* Cannot compute PTS if not present (we can compute it only
* by knowing the future. */