NetEq: Fixing an overflow bug in expand.cc

The overflow currently does not cause any problems, but it has been
found that it can cause crashes after a refactoring that is coming in
the near future.

Bug: webrtc:9180
Change-Id: Ia2c4e545c062c4f8ad13cbc47b8796c6e8a4e906
Reviewed-on: https://webrtc-review.googlesource.com/77667
Reviewed-by: Ivo Creusen <ivoc@webrtc.org>
Commit-Queue: Henrik Lundin <henrik.lundin@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23327}
This commit is contained in:
Henrik Lundin
2018-05-21 13:41:16 +02:00
committed by Commit Bot
parent 3ca48a69fd
commit 9024da84c9
2 changed files with 9 additions and 9 deletions

View File

@ -743,9 +743,9 @@ void Expand::AnalyzeSignal(int16_t* random_vector) {
// the division.
// Shift the denominator from Q13 to Q5 before the division. The result of
// the division will then be in Q20.
int temp_ratio = WebRtcSpl_DivW32W16(
(slope - 8192) << 12,
static_cast<int16_t>((distortion_lag * slope) >> 8));
int16_t denom =
rtc::saturated_cast<int16_t>((distortion_lag * slope) >> 8);
int temp_ratio = WebRtcSpl_DivW32W16((slope - 8192) << 12, denom);
if (slope > 14746) {
// slope > 1.8.
// Divide by 2, with proper rounding.