Commit df33a58e authored by Anton Khirnov's avatar Anton Khirnov

lavf: avoid integer overflow when estimating bitrate

Reported-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
CC: libav-stable@libav.org
parent fab694dd
......@@ -1757,8 +1757,13 @@ static void estimate_timings_from_bit_rate(AVFormatContext *ic)
int bit_rate = 0;
for(i=0;i<ic->nb_streams;i++) {
st = ic->streams[i];
if (st->codec->bit_rate > 0)
bit_rate += st->codec->bit_rate;
if (st->codec->bit_rate > 0) {
if (INT_MAX - st->codec->bit_rate > bit_rate) {
bit_rate = 0;
break;
}
bit_rate += st->codec->bit_rate;
}
}
ic->bit_rate = bit_rate;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment