WebRtcIlbcfix_Smooth: Fix UBSan fuzzer bug (left shift of 1 by 31 overflows)

scale1 == 31 if and only if w10 == 0. So even though 1 << scale1
overflows, we know that the result of the multiplication should be 0.
Handle that case.

BUG=chromium:615818

Review-Url: https://codereview.webrtc.org/2258543002
Cr-Commit-Position: refs/heads/master@{#13847}
This commit is contained in:
kwiberg
2016-08-22 07:43:42 -07:00
committed by Commit bot
parent 642e3bc75b
commit 7f82fc988d

View File

@ -168,7 +168,7 @@ void WebRtcIlbcfix_Smooth(
/* B_W32 is in Q30 ( B = 1 - ENH_A0/2 - A * w10/w00 ) */
scale1 = 31-bitsw10;
scale2 = 21-scale1;
w10prim = w10 * (1 << scale1);
w10prim = w10 == 0 ? 0 : w10 * (1 << scale1);
w00prim = WEBRTC_SPL_SHIFT_W32(w00, -scale2);
scale = bitsw00-scale2-15;