summaryrefslogtreecommitdiffstats
path: root/gpu/command_buffer/common/gles2_cmd_utils.h
diff options
context:
space:
mode:
Diffstat (limited to 'gpu/command_buffer/common/gles2_cmd_utils.h')
-rw-r--r--gpu/command_buffer/common/gles2_cmd_utils.h5
1 files changed, 3 insertions, 2 deletions
diff --git a/gpu/command_buffer/common/gles2_cmd_utils.h b/gpu/command_buffer/common/gles2_cmd_utils.h
index c5cd792..318d2d8 100644
--- a/gpu/command_buffer/common/gles2_cmd_utils.h
+++ b/gpu/command_buffer/common/gles2_cmd_utils.h
@@ -18,12 +18,13 @@ namespace gles2 {
// returns true.
template <typename T>
inline bool SafeMultiply(T a, T b, T* dst) {
- *dst = 0;
if (b == 0) {
+ *dst = 0;
return true;
}
T v = a * b;
if (v / b != a) {
+ *dst = 0;
return false;
}
*dst = v;
@@ -38,8 +39,8 @@ inline bool SafeMultiplyUint32(uint32 a, uint32 b, uint32* dst) {
// Does an add checking for overflow. If there was no overflow returns true.
template <typename T>
inline bool SafeAdd(T a, T b, T* dst) {
- *dst = 0;
if (a + b < a) {
+ *dst = 0;
return false;
}
*dst = a + b;