Skip to content

Commit dc131b1

Browse files
committed
Fix overflow in rehash_in_place
1 parent 431e7ac commit dc131b1

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/raw/mod.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -554,8 +554,9 @@ impl<T> RawTable<T> {
554554
// size. If both the new and old position fall within the
555555
// same unaligned group, then there is no benefit in moving
556556
// it and we can just continue to the next item.
557-
let probe_index = |pos| {
558-
((pos - guard.probe_seq(hash).offset) & guard.bucket_mask) / Group::WIDTH
557+
let probe_index = |pos: usize| {
558+
(pos.wrapping_sub(guard.probe_seq(hash).offset) & guard.bucket_mask)
559+
/ Group::WIDTH
559560
};
560561
if likely(probe_index(i) == probe_index(new_i)) {
561562
guard.set_ctrl(i, h2(hash));

0 commit comments

Comments
 (0)