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

Unified Diff: webrtc/common_audio/signal_processing/dot_product_with_scale.c

Issue 2717123004: Avoid overflow in WebRtcSpl_DotProductWithScale (Closed)
Patch Set: Created 3 years, 10 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/common_audio/signal_processing/dot_product_with_scale.c
diff --git a/webrtc/common_audio/signal_processing/dot_product_with_scale.c b/webrtc/common_audio/signal_processing/dot_product_with_scale.c
index 1302d62541266fdc45b07576de5ff5026d69032f..202d0ccd6c93890bd4cf8e5ef6583235c7b33a7d 100644
--- a/webrtc/common_audio/signal_processing/dot_product_with_scale.c
+++ b/webrtc/common_audio/signal_processing/dot_product_with_scale.c
@@ -14,7 +14,7 @@ int32_t WebRtcSpl_DotProductWithScale(const int16_t* vector1,
const int16_t* vector2,
size_t length,
int scaling) {
- int32_t sum = 0;
+ int64_t sum = 0;
size_t i = 0;
/* Unroll the loop to improve performance. */
@@ -28,5 +28,5 @@ int32_t WebRtcSpl_DotProductWithScale(const int16_t* vector1,
sum += (vector1[i] * vector2[i]) >> scaling;
}
- return sum;
+ return (int32_t) sum;
kwiberg-webrtc 2017/02/28 10:07:47 You'll get garbage if this cast truncates. And was
hlundin-webrtc 2017/02/28 11:58:45 Done.
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698