Fixes one issue in the function itself and one in the dependent
function av_add_stable() which wasn't checking for NaN.

Signed-off-by: Dale Curtis <dalecur...@chromium.org>
---
 libavformat/utils.c     | 2 +-
 libavutil/mathematics.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
From fbe9f4552d7153286cfa50d3f03b5e474f6a9a66 Mon Sep 17 00:00:00 2001
From: Dale Curtis <dalecurtis@chromium.org>
Date: Thu, 14 May 2020 14:47:49 -0700
Subject: [PATCH 4/5] [utils, mathematics] Fix overflow in
 compute_pkt_fields().

Fixes one issue in the function itself and one in the dependent
function av_add_stable() which wasn't checking for NaN.

Signed-off-by: Dale Curtis <dalecurtis@chromium.org>
---
 libavformat/utils.c     | 2 +-
 libavutil/mathematics.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavformat/utils.c b/libavformat/utils.c
index 107ab05b9a..f3bea05cf4 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -1359,7 +1359,7 @@ static void compute_pkt_fields(AVFormatContext *s, AVStream *st,
             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;
+                st->cur_dts = av_sat_add64(pkt->dts, st->last_IP_duration);
             if (pkt->dts != AV_NOPTS_VALUE &&
                 pkt->pts == AV_NOPTS_VALUE &&
                 st->last_IP_duration > 0 &&
diff --git a/libavutil/mathematics.c b/libavutil/mathematics.c
index 0485db7222..16c6e4db03 100644
--- a/libavutil/mathematics.c
+++ b/libavutil/mathematics.c
@@ -207,7 +207,7 @@ int64_t av_add_stable(AVRational ts_tb, int64_t ts, AVRational inc_tb, int64_t i
         int64_t old = av_rescale_q(ts, ts_tb, inc_tb);
         int64_t old_ts = av_rescale_q(old, inc_tb, ts_tb);

-        if (old == INT64_MAX)
+        if (old == INT64_MAX || old == AV_NOPTS_VALUE || old_ts == AV_NOPTS_VALUE)
             return ts;

         return av_rescale_q(old + 1, inc_tb, ts_tb) + (ts - old_ts);
--
2.26.2.761.g0e0b3e54be-goog

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Reply via email to