Skip to content

Commit

Permalink
unsigned overflow in find_last_elem (found by some tier6 tests)
Browse files Browse the repository at this point in the history
  • Loading branch information
cl4es committed Nov 8, 2020
1 parent e46634f commit fde1fc5
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/hotspot/share/opto/regmask.hpp
Expand Up @@ -178,8 +178,10 @@ class RegMask {
// Get highest-numbered register from mask, or BAD if mask is empty.
OptoReg::Name find_last_elem() const {
assert(valid_watermarks(), "sanity");
for (unsigned i = _hwm; i >= _lwm; i--) {
uintptr_t bits = _RM_UP[i];
// Careful not to overflow if _lwm == 0
unsigned i = _hwm + 1;
while (i > _lwm) {
uintptr_t bits = _RM_UP[--i];
if (bits) {
return OptoReg::Name((i<<_LogWordBits) + find_highest_bit(bits));
}
Expand Down

0 comments on commit fde1fc5

Please sign in to comment.