diff options
author | Martin Storsjö <martin@martin.st> | 2013-07-15 16:44:20 +0300 |
---|---|---|
committer | Martin Storsjö <martin@martin.st> | 2013-07-15 21:39:24 +0300 |
commit | e740929a071ab032ffa382e89da69c6ec7cf882c (patch) | |
tree | 7f0e62e8d641687a68b8fd3110695472a8b97040 | |
parent | 31931520df35a6f9606fe8293c8a39e2d1fabedf (diff) | |
download | ffmpeg-e740929a071ab032ffa382e89da69c6ec7cf882c.tar.gz |
lavf: Make sure avg_frame_rate can be calculated without integer overflow
If either of the deltas is too large for the multiplications to
succeed, don't use this for setting the avg frame rate.
Reported-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Cc: libav-stable@libav.org
Signed-off-by: Martin Storsjö <martin@martin.st>
-rw-r--r-- | libavformat/utils.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/libavformat/utils.c b/libavformat/utils.c index d83c73697f..80b1ce2f7c 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -2355,6 +2355,9 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options) int best_fps = 0; double best_error = 0.01; + if (delta_dts >= INT64_MAX / st->time_base.num || + delta_packets >= INT64_MAX / st->time_base.den) + continue; av_reduce(&st->avg_frame_rate.num, &st->avg_frame_rate.den, delta_packets*(int64_t)st->time_base.den, delta_dts*(int64_t)st->time_base.num, 60000); |