aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--components/hashglobe/src/table.rs4
1 files changed, 3 insertions, 1 deletions
diff --git a/components/hashglobe/src/table.rs b/components/hashglobe/src/table.rs
index 0fe08f2b052..e418c11b04d 100644
--- a/components/hashglobe/src/table.rs
+++ b/components/hashglobe/src/table.rs
@@ -836,7 +836,9 @@ impl<K, V> RawTable<K, V> {
pub fn new(capacity: usize) -> Result<RawTable<K, V>, FailedAllocationError> {
unsafe {
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)
}
}