| Index: runtime/vm/object.cc
|
| diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc
|
| index 7b0e4cadb9d46fe32a771ea06dd592e900b6cf3e..b2b922b9888876b4bbc48aaa3217edad5b2bed53 100644
|
| --- a/runtime/vm/object.cc
|
| +++ b/runtime/vm/object.cc
|
| @@ -4544,7 +4544,10 @@ static uint32_t FinalizeHash(uint32_t hash, intptr_t hashbits) {
|
| hash += hash << 3;
|
| hash ^= hash >> 11; // Logical shift, unsigned hash.
|
| hash += hash << 15;
|
| - hash &= (static_cast<uint32_t>(1) << hashbits) - 1;
|
| + // FinalizeHash gets called with values for hashbits that are bigger than 31
|
| + // (like kBitsPerWord - 1). Therefore we are careful to use a type
|
| + // (uintptr_t) big enough to avoid undefined behavior with the left shift.
|
| + hash &= (static_cast<uintptr_t>(1) << hashbits) - 1;
|
| return (hash == 0) ? 1 : hash;
|
| }
|
|
|
|
|