Fix for overflow in iLBC code.

The calculation of the necessary number of shifts is not correct, leading to an overflow.

Bug: chromium:1158070
Change-Id: I6545e9da46debf33ce169c33d762915fe755d606
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/197981
Reviewed-by: Henrik Lundin <henrik.lundin@webrtc.org>
Commit-Queue: Ivo Creusen <ivoc@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#32855}
This commit is contained in:
Ivo Creusen
2020-12-16 17:37:58 +01:00
committed by Commit Bot
parent c25a3a3a1e
commit 0ff2b4cd42

View File

@ -202,10 +202,10 @@ size_t // (o) Estimated lag in end of in[]
/* scaling */
max16 = WebRtcSpl_MaxAbsValueW16(regressor, plc_blockl + 3 - 1);
if (max16>5000)
shifts=2;
else
shifts=0;
const int64_t max_val = plc_blockl * max16 * max16;
const int32_t factor = max_val >> 31;
shifts = factor == 0 ? 0 : 31 - WebRtcSpl_NormW32(factor);
/* compute cross correlation */
WebRtcSpl_CrossCorrelation(corr32, target, regressor, plc_blockl, 3, shifts,