From 3fc8e8dde365392da56724a33c2b8a05f5da75d2 Mon Sep 17 00:00:00 2001 From: kwiberg Date: Fri, 20 May 2016 04:40:29 -0700 Subject: [PATCH] Fix UBSan errors (left shift of negative value) BUG=chromium:604803 Review-Url: https://codereview.webrtc.org/1988113003 Cr-Commit-Position: refs/heads/master@{#12826} --- webrtc/modules/audio_coding/codecs/ilbc/do_plc.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/webrtc/modules/audio_coding/codecs/ilbc/do_plc.c b/webrtc/modules/audio_coding/codecs/ilbc/do_plc.c index f74439ede6..ebddec3f5e 100644 --- a/webrtc/modules/audio_coding/codecs/ilbc/do_plc.c +++ b/webrtc/modules/audio_coding/codecs/ilbc/do_plc.c @@ -119,12 +119,14 @@ void WebRtcIlbcfix_DoThePlc( /* Calculate shift value, so that the two measures can be put in the same Q domain */ - if(((shiftMax<<1)+shift3) > ((shift1<<1)+shift2)) { - tmp1 = WEBRTC_SPL_MIN(31, (shiftMax<<1)+shift3-(shift1<<1)-shift2); + if(2 * shiftMax + shift3 > 2 * shift1 + shift2) { + tmp1 = + WEBRTC_SPL_MIN(31, 2 * shiftMax + shift3 - 2 * shift1 - shift2); tmp2 = 0; } else { tmp1 = 0; - tmp2 = WEBRTC_SPL_MIN(31, (shift1<<1)+shift2-(shiftMax<<1)-shift3); + tmp2 = + WEBRTC_SPL_MIN(31, 2 * shift1 + shift2 - 2 * shiftMax - shift3); } if ((measure>>tmp1) > (maxMeasure>>tmp2)) {