]> git.sesse.net Git - ffmpeg/commitdiff
avutil/mathematics: Use av_sat_add64() for the last addition in av_add_stable()
authorMichael Niedermayer <michael@niedermayer.cc>
Tue, 20 Oct 2020 20:10:39 +0000 (22:10 +0200)
committerMichael Niedermayer <michael@niedermayer.cc>
Sun, 25 Oct 2020 08:49:21 +0000 (09:49 +0100)
Fixes: signed integer overflow: 9223372036854770375 + 5450 cannot be represented in type 'long'
Fixes: 26471/clusterfuzz-testcase-minimized-ffmpeg_dem_MXG_fuzzer-6229617557635072
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavutil/mathematics.c

index 16c6e4db030e9d8323d7cab67b00a7148993ee16..da0fc17b2e655a33d35cb5711d55560f8406f8d2 100644 (file)
@@ -210,6 +210,6 @@ int64_t av_add_stable(AVRational ts_tb, int64_t ts, AVRational inc_tb, int64_t i
         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);
+        return av_sat_add64(av_rescale_q(old + 1, inc_tb, ts_tb), ts - old_ts);
     }
 }