Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(198)

Unified Diff: webrtc/modules/audio_coding/codecs/isac/main/source/entropy_coding.c

Issue 1979973003: Fix UBSan errors (left shift of negative value, left shift overflows int) (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/modules/audio_coding/codecs/isac/main/source/entropy_coding.c
diff --git a/webrtc/modules/audio_coding/codecs/isac/main/source/entropy_coding.c b/webrtc/modules/audio_coding/codecs/isac/main/source/entropy_coding.c
index c1204ad03adcbcae5175824818ee92f2c24e6928..849834e552e2a0eb007c187f508bcd78efec552a 100644
--- a/webrtc/modules/audio_coding/codecs/isac/main/source/entropy_coding.c
+++ b/webrtc/modules/audio_coding/codecs/isac/main/source/entropy_coding.c
@@ -162,9 +162,9 @@ static void FindInvArSpec(const int16_t* ARCoefQ12,
}
for (k = 0; k < FRAMESAMPLES / 8; k++) {
- CurveQ16[FRAMESAMPLES_QUARTER - 1 - k] = CurveQ16[k] -
- (diffQ16[k] << shftVal);
- CurveQ16[k] += diffQ16[k] << shftVal;
+ int32_t d = (int32_t)((uint32_t)(diffQ16[k]) << shftVal);
tlegrand-webrtc 2016/05/17 12:43:37 "d" is not a very nice variable name. Can you rena
kwiberg-webrtc 2016/05/17 13:10:39 Yes, "d" is short and therefore not very descripti
tlegrand-webrtc 2016/05/17 14:01:06 Yes, sorry, it is of course taken. I've had troubl
kwiberg-webrtc 2016/05/18 08:21:06 Yes, but that's not all that relevant for variable
+ CurveQ16[FRAMESAMPLES_QUARTER - 1 - k] = CurveQ16[k] - d;
+ CurveQ16[k] += d;
kwiberg-webrtc 2016/05/16 14:05:37 diffQ16[k] was sometimes negative, and left shift
}
}

Powered by Google App Engine
This is Rietveld 408576698