Auto merge of #18751 - bholley:poison_hashtable, r=Manishearth

Poison hashtable buffers

This gives us extra defense in depth.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/18751)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2017-10-04 23:54:56 -05:00 committed by GitHub
commit 2bbc458c5b

View file

@ -777,13 +777,16 @@ impl<K, V> RawTable<K, V> {
// FORK NOTE: Uses alloc shim instead of Heap.alloc
let buffer = alloc(size, alignment);
let buffer: *mut u8 = alloc(size, alignment);
if buffer.is_null() {
return Err(FailedAllocationError { reason: "out of memory when allocating RawTable" });
}
// FORK NOTE: poison the entire buffer rather than leaving it uninitialized.
ptr::write_bytes(buffer, 0xe7, size);
let hashes = buffer.offset(hash_offset as isize) as *mut HashUint;
Ok(RawTable {