mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 768538 - 1/2 - Fix undefined behavior in CheckedInt - r=jwalden
This commit is contained in:
parent
719a318e65
commit
91d02dae9f
@ -678,11 +678,13 @@ inline CheckedInt<T> operator OP(const CheckedInt<T> &lhs, \
|
||||
{ \
|
||||
T x = lhs.mValue; \
|
||||
T y = rhs.mValue; \
|
||||
T result = x OP y; \
|
||||
T isOpValid = detail::Is##NAME##Valid(x, y); \
|
||||
/* Help the compiler perform RVO (return value optimization). */ \
|
||||
return CheckedInt<T>(result, \
|
||||
lhs.mIsValid && rhs.mIsValid && isOpValid); \
|
||||
if (isOpValid) { \
|
||||
T result = x OP y; \
|
||||
return CheckedInt<T>(result, lhs.mIsValid && rhs.mIsValid); \
|
||||
} else { \
|
||||
return CheckedInt<T>(T(0), false); \
|
||||
} \
|
||||
}
|
||||
|
||||
MOZ_CHECKEDINT_BASIC_BINARY_OPERATOR(Add, +)
|
||||
|
Loading…
Reference in New Issue
Block a user