Skip to content

Commit

Permalink
Fix incorrect comparison
Browse files Browse the repository at this point in the history
The integer overflow comparison was using an incorrect numeric limit for
half of the check as noted by comments in issue #208.  It looks like
this was a copy/paste error when CheckAdd() was updated to support other
types besides integers by bd5630b.
  • Loading branch information
nick-potenski committed Apr 18, 2023
1 parent 52948c1 commit 2d353b3
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/bloaty.cc
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ void CheckedAdd(int64_t* accum, int64_t val) {
}
#else
bool safe = *accum < 0
? (val >= std::numeric_limits<int64_t>::max() - *accum)
? (val >= std::numeric_limits<int64_t>::min() - *accum)
: (val <= std::numeric_limits<int64_t>::max() - *accum);
if (!safe) {
THROW("integer overflow");
Expand Down

0 comments on commit 2d353b3

Please sign in to comment.