From 4843dd13aa3426d9a3caee768fc015d8731c5d18 Mon Sep 17 00:00:00 2001 From: ivoc Date: Mon, 9 Jan 2017 08:31:42 -0800 Subject: [PATCH] Fix for left-shift of potentially negative values in NetEq. Left shifting negative integers is undefined behavior, and should be prevented. This CL fixes one such instance in the NetEq Expand function. BUG=chromium:677106 Review-Url: https://codereview.webrtc.org/2616363003 Cr-Commit-Position: refs/heads/master@{#15966} --- webrtc/modules/audio_coding/neteq/expand.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webrtc/modules/audio_coding/neteq/expand.cc b/webrtc/modules/audio_coding/neteq/expand.cc index da870d7706..2154bfde63 100644 --- a/webrtc/modules/audio_coding/neteq/expand.cc +++ b/webrtc/modules/audio_coding/neteq/expand.cc @@ -441,7 +441,7 @@ void Expand::AnalyzeSignal(int16_t* random_vector) { for (size_t i = 0; i < kNumCorrelationCandidates; ++i) { int32_t ratio; if (best_distortion[i] > 0) { - ratio = (best_correlation[i] << 16) / best_distortion[i]; + ratio = (best_correlation[i] * (1 << 16)) / best_distortion[i]; } else if (best_correlation[i] == 0) { ratio = 0; // No correlation set result to zero. } else {