You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Replace (hash as usize) & self.mask with (hash & (self.mask as u64)) as usize to prevent overflow.
You may also want to change the type of self.mask to u64
The text was updated successfully, but these errors were encountered:
Kakusakov
changed the title
indexing cache_table::CacheTable on 32-bit systems may cause overflow
Indexing cache_table::CacheTable on 32-bit systems may cause overflow
Nov 1, 2024
chess/src/cache_table.rs
Line 39 in 0e538fb
chess/src/cache_table.rs
Line 50 in 0e538fb
chess/src/cache_table.rs
Line 83 in 0e538fb
On 32-bit systems
hash as usize
will overflow if the value ofhash
is greater thanu32::MAX
.This overflow is mostly harmless in release mode (as the hash will just be truncated to the 32-bit boundary), but it will cause a panic in debug mode.
Replace
(hash as usize) & self.mask
with(hash & (self.mask as u64)) as usize
to prevent overflow.You may also want to change the type of
self.mask
tou64
The text was updated successfully, but these errors were encountered: