1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

avutil/mathematics: Fix overflow with NaN in av_add_stable()

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
Dale Curtis 2020-05-14 14:47:49 -07:00 committed by Michael Niedermayer
parent 63ce7c71bc
commit d9aa1ef2c2

View File

@ -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 = av_rescale_q(ts, ts_tb, inc_tb);
int64_t old_ts = av_rescale_q(old, inc_tb, ts_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 ts;
return av_rescale_q(old + 1, inc_tb, ts_tb) + (ts - old_ts); return av_rescale_q(old + 1, inc_tb, ts_tb) + (ts - old_ts);