diff options
author | Mike Frysinger <vapier@chromium.org> | 2016-01-15 13:29:32 -0500 |
---|---|---|
committer | Mike Frysinger <vapier@chromium.org> | 2016-01-15 13:29:32 -0500 |
commit | 126a938fef232f9519499e255a974dbab8ba451b (patch) | |
tree | 41642c7c7434f0fa60dde213edf31736839c8916 | |
parent | README: add more links to breakpad sites (diff) | |
download | breakpad-126a938fef232f9519499e255a974dbab8ba451b.tar.xz |
breakpad: fix unittest failure when building with clang.
In C/C++, the result of signed integer overflow is undefined.
The expression "base + size - 1" is parsed as "(base + size) - 1", and
"base + size" can overflow even if "base + (size - 1)" <= INT_MAX.
See http://g/c-compiler-chrome/461JohPKakE/JI3rEBg6FwAJ for more.
BUG=None
TEST='CC=clang CXX=clang++ ./configure && make check'
R=vapier@chromium.org
Review URL: https://codereview.chromium.org/1591793002 .
-rw-r--r-- | src/processor/range_map-inl.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/processor/range_map-inl.h b/src/processor/range_map-inl.h index 55dae839..25604080 100644 --- a/src/processor/range_map-inl.h +++ b/src/processor/range_map-inl.h @@ -50,7 +50,7 @@ template<typename AddressType, typename EntryType> bool RangeMap<AddressType, EntryType>::StoreRange(const AddressType &base, const AddressType &size, const EntryType &entry) { - AddressType high = base + size - 1; + AddressType high = base + (size - 1); // Check for undersize or overflow. if (size <= 0 || high < base) { |