mirror of
https://github.com/servo/servo.git
synced 2025-08-05 05:30:08 +01:00
Fix UB in hashglobe
This commit is contained in:
parent
6ae238e868
commit
0115eb8dd8
1 changed files with 3 additions and 1 deletions
|
@ -836,7 +836,9 @@ impl<K, V> RawTable<K, V> {
|
||||||
pub fn new(capacity: usize) -> Result<RawTable<K, V>, FailedAllocationError> {
|
pub fn new(capacity: usize) -> Result<RawTable<K, V>, FailedAllocationError> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let ret = RawTable::try_new_uninitialized(capacity)?;
|
let ret = RawTable::try_new_uninitialized(capacity)?;
|
||||||
ptr::write_bytes(ret.hashes.ptr(), 0, capacity);
|
if capacity > 0 {
|
||||||
|
ptr::write_bytes(ret.hashes.ptr(), 0, capacity);
|
||||||
|
}
|
||||||
Ok(ret)
|
Ok(ret)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue