From efa26d7468ca850b65d28d742b9e5fc7f6d19380 Mon Sep 17 00:00:00 2001 From: Amit Mishra Date: Sat, 4 Jul 2026 02:29:03 +0530 Subject: [PATCH] Use wrapping arithmetic in ProbeSeq::move_next to avoid overflow In long probe sequences with a nearly-full table, the stride and pos fields can overflow using plain += before being masked back. Replacing the additions with wrapping_add makes the arithmetic well-defined under all inputs and matches the intent of the subsequent mask (& bucket_mask). Fixes #735 Assisted-By: Claude Sonnet 4.6 --- src/raw.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/raw.rs b/src/raw.rs index d42ae430d..94f3a177c 100644 --- a/src/raw.rs +++ b/src/raw.rs @@ -87,9 +87,8 @@ impl ProbeSeq { "Went past end of probe sequence" ); - self.stride += Group::WIDTH; - self.pos += self.stride; - self.pos &= bucket_mask; + self.stride = self.stride.wrapping_add(Group::WIDTH); + self.pos = self.pos.wrapping_add(self.stride) & bucket_mask; } }