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

Unified Diff: src/runtime.cc

Issue 382153003: Make UBSan happy. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: rebased Created 6 years, 5 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 | « src/hydrogen-instructions.cc ('k') | src/strtod.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/runtime.cc
diff --git a/src/runtime.cc b/src/runtime.cc
index 28481383a5fbd846a6940deb9a1b08ee64dab56e..f3e8e842693c9335d717467964014283188e5c81 100644
--- a/src/runtime.cc
+++ b/src/runtime.cc
@@ -7009,9 +7009,12 @@ RUNTIME_FUNCTION(Runtime_NumberImul) {
HandleScope scope(isolate);
ASSERT(args.length() == 2);
- CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]);
- CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]);
- return *isolate->factory()->NewNumberFromInt(x * y);
+ // We rely on implementation-defined behavior below, but at least not on
+ // undefined behavior.
+ CONVERT_NUMBER_CHECKED(uint32_t, x, Int32, args[0]);
+ CONVERT_NUMBER_CHECKED(uint32_t, y, Int32, args[1]);
+ int32_t product = static_cast<int32_t>(x * y);
+ return *isolate->factory()->NewNumberFromInt(product);
}
« no previous file with comments | « src/hydrogen-instructions.cc ('k') | src/strtod.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698