diff mbox

[FFmpeg-devel] lavf/utils: Avoid an overflow for huge negative durations.

Message ID 201609241310.35616.cehoyos@ag.or.at
State Accepted
Commit 267da70ea8c36caaa645a3c4f1c5f0ca8bae156a
Headers show

Commit Message

Carl Eugen Hoyos Sept. 24, 2016, 11:10 a.m. UTC
Hi!

Attached patch hopefully fixes ticket #5135.

Please review, Carl Eugen
From 12a33bb9d5475701009a60af79fa7699416b50e7 Mon Sep 17 00:00:00 2001
From: Carl Eugen Hoyos <cehoyos@ag.or.at>
Date: Sat, 24 Sep 2016 13:07:39 +0200
Subject: [PATCH] lavf/utils: Avoid an overflow for huge negative durations.

Fixes ticket #5135.
---
 libavformat/utils.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Michael Niedermayer Sept. 24, 2016, 5:51 p.m. UTC | #1
On Sat, Sep 24, 2016 at 01:10:35PM +0200, Carl Eugen Hoyos wrote:
> Hi!
> 
> Attached patch hopefully fixes ticket #5135.
> 
> Please review, Carl Eugen

>  utils.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 361dc2ec60e39c2b0822c5c944f93469c237814b  0001-lavf-utils-Avoid-an-overflow-for-huge-negative-durat.patch
> From 12a33bb9d5475701009a60af79fa7699416b50e7 Mon Sep 17 00:00:00 2001
> From: Carl Eugen Hoyos <cehoyos@ag.or.at>
> Date: Sat, 24 Sep 2016 13:07:39 +0200
> Subject: [PATCH] lavf/utils: Avoid an overflow for huge negative durations.
> 
> Fixes ticket #5135.

LGTM

please also backport

thx

[...]
Carl Eugen Hoyos Sept. 24, 2016, 7:13 p.m. UTC | #2
2016-09-24 19:51 GMT+02:00 Michael Niedermayer <michael@niedermayer.cc>:
> On Sat, Sep 24, 2016 at 01:10:35PM +0200, Carl Eugen Hoyos wrote:
>> Hi!
>>
>> Attached patch hopefully fixes ticket #5135.

>> Fixes ticket #5135.
>
> LGTM

Patch applied.

> please also backport

Done.

Thank you, Carl Eugen
diff mbox

Patch

diff --git a/libavformat/utils.c b/libavformat/utils.c
index 93ea6ff..3e0f57d 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -2547,7 +2547,7 @@  static void update_stream_timings(AVFormatContext *ic)
             end_time1 = av_rescale_q_rnd(st->duration, st->time_base,
                                          AV_TIME_BASE_Q,
                                          AV_ROUND_NEAR_INF|AV_ROUND_PASS_MINMAX);
-            if (end_time1 != AV_NOPTS_VALUE && start_time1 <= INT64_MAX - end_time1) {
+            if (end_time1 != AV_NOPTS_VALUE && (end_time1 > 0 ? start_time1 <= INT64_MAX - end_time1 : start_time1 >= INT64_MIN - end_time1)) {
                 end_time1 += start_time1;
                 end_time = FFMAX(end_time, end_time1);
             }