diff options
author | Kinan Hakim <kinan@google.com> | 2016-01-26 17:39:42 +0100 |
---|---|---|
committer | Kinan Hakim <kinan@google.com> | 2016-01-26 17:39:42 +0100 |
commit | 3c5bda32ce3dd64d94739177efd9d84764b545f4 (patch) | |
tree | 5ccf2a53b0a5d786d494740d5c6dabc0bfe4164d | |
parent | 104113430e31f8ee04f7b66608d9190488482be3 (diff) | |
download | dng_sdk-3c5bda32ce3dd64d94739177efd9d84764b545f4.tar.gz |
Fix integer overflow
-rw-r--r-- | source/dng_point.h | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/source/dng_point.h b/source/dng_point.h index 66e3ec9..e92e93a 100644 --- a/source/dng_point.h +++ b/source/dng_point.h @@ -19,6 +19,7 @@ /*****************************************************************************/
#include "dng_types.h"
+#include "dng_safe_arithmetic.h"
#include "dng_utils.h"
/*****************************************************************************/
@@ -109,19 +110,14 @@ class dng_point_real64 /*****************************************************************************/
-#if defined(__clang__) && defined(__has_attribute)
-#if __has_attribute(no_sanitize)
-__attribute__((no_sanitize("signed-integer-overflow")))
-#endif
-#endif
inline dng_point operator+ (const dng_point &a,
const dng_point &b)
{
- return dng_point (a.v + b.v,
- a.h + b.h);
+ return dng_point (SafeInt32Add(a.v, b.v),
+ SafeInt32Add(a.h, b.h));
}
@@ -146,8 +142,8 @@ inline dng_point operator- (const dng_point &a, {
- return dng_point (a.v - b.v,
- a.h - b.h);
+ return dng_point (SafeInt32Sub(a.v, b.v),
+ SafeInt32Sub(a.h, b.h));
}
|