aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat/utils.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2018-10-12 20:55:25 +0200
committerMichael Niedermayer <michael@niedermayer.cc>2018-10-28 02:22:42 +0200
commitd17d08035cd4e8cc6782ad251d39b6c61913518e (patch)
treeb4cc6807025394410d9a9b972e154dc02763ef8e /libavformat/utils.c
parente9975d1b511812984f208128711a6aa68eddf82a (diff)
downloadffmpeg-d17d08035cd4e8cc6782ad251d39b6c61913518e.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>
Diffstat (limited to 'libavformat/utils.c')
-rw-r--r--libavformat/utils.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/libavformat/utils.c b/libavformat/utils.c
index db79577548..27071e10b4 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -1314,7 +1314,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;
@@ -1326,7 +1326,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. */