NetEq: Changing checked_cast to saturated_cast

The cast involves packet_len_samp, which is derived from the timestamps
and sequence numbers of incoming packets. Being values from the outside,
these should be treated as if any value is possible, making a
checked_cast unsuitable. Changing instead to saturated_cast to avoid
overflow with out-of-bounds values.

Review-Url: https://codereview.webrtc.org/2243403007
Cr-Commit-Position: refs/heads/master@{#13815}
This commit is contained in:
henrik.lundin
2016-08-18 03:49:32 -07:00
committed by Commit bot
parent 96bbdd585e
commit 38d840c35a

View File

@ -98,7 +98,7 @@ int DelayManager::Update(uint16_t sequence_number,
static_cast<uint32_t>(timestamp - last_timestamp_) /
static_cast<uint16_t>(sequence_number - last_seq_no_);
packet_len_ms =
rtc::checked_cast<int>(1000 * packet_len_samp / sample_rate_hz);
rtc::saturated_cast<int>(1000 * packet_len_samp / sample_rate_hz);
}
if (packet_len_ms > 0) {