Reviewers: Yang,

Message:
PTAL.

Description:
Update safe_math_impl.h

Porting Chromium's https://codereview.chromium.org/1142783002/ to fix a
division-by-zero bug.

BUG=chromium:488302
LOG=n

Please review this at https://codereview.chromium.org/1135293003/

Base URL: https://chromium.googlesource.com/v8/v8.git@master

Affected files (+2, -2 lines):
  M src/base/safe_math_impl.h


Index: src/base/safe_math_impl.h
diff --git a/src/base/safe_math_impl.h b/src/base/safe_math_impl.h
index 055e2a0275038893e707da0b1b734dfb7e9d9c19..eb2a151191bba51e1dcc3fdff932ff2ded7fbafb 100644
--- a/src/base/safe_math_impl.h
+++ b/src/base/safe_math_impl.h
@@ -208,8 +208,8 @@ typename enable_if<std::numeric_limits<T>::is_integer &&
                        (sizeof(T) * 2 > sizeof(uintmax_t)),
                    T>::type
 CheckedMul(T x, T y, RangeConstraint* validity) {
-  // if either side is zero then the result will be zero.
-  if (!(x || y)) {
+  // If either side is zero then the result will be zero.
+  if (!x || !y) {
     return RANGE_VALID;

   } else if (x > 0) {


--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to