Skip to content

Commit 0115eb8

Browse files
committed
Fix UB in hashglobe
1 parent 6ae238e commit 0115eb8

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

components/hashglobe/src/table.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -836,7 +836,9 @@ impl<K, V> RawTable<K, V> {
836836
pub fn new(capacity: usize) -> Result<RawTable<K, V>, FailedAllocationError> {
837837
unsafe {
838838
let ret = RawTable::try_new_uninitialized(capacity)?;
839-
ptr::write_bytes(ret.hashes.ptr(), 0, capacity);
839+
if capacity > 0 {
840+
ptr::write_bytes(ret.hashes.ptr(), 0, capacity);
841+
}
840842
Ok(ret)
841843
}
842844
}

0 commit comments

Comments
 (0)