NetEq: Fix an UBSan error

UBSan will trigger when shifting a negative value. This change avoids
that by replacing "x << 8" with "x * (1 << 8)".

Bug: chromium:666877
Change-Id: Ic89bd98e5a3feff35075df96b104b386cb4d8803
Reviewed-on: https://webrtc-review.googlesource.com/14552
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Commit-Queue: Henrik Lundin <henrik.lundin@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#20387}
This commit is contained in:
Henrik Lundin
2017-10-23 11:36:01 +02:00
committed by Commit Bot
parent 9155e4986d
commit 8731176b92

View File

@ -40,9 +40,9 @@ void BufferLevelFilter::Update(size_t buffer_size_packets,
// value of |time_stretched_samples| from |filtered_current_level_| after
// converting |time_stretched_samples| from samples to packets in Q8.
// Make sure that the filtered value remains non-negative.
filtered_current_level_ = std::max(0,
filtered_current_level_ -
(time_stretched_samples << 8) / static_cast<int>(packet_len_samples));
filtered_current_level_ = std::max(
0, filtered_current_level_ - (time_stretched_samples * (1 << 8)) /
static_cast<int>(packet_len_samples));
}
}