Non-Unix arena: use zeroed alloc to avoid UB

Reads to the arena were flagged by Miri as UB since it contained
uninitialized memory
This commit is contained in:
Bob Peterson
2025-10-13 13:53:07 -05:00
parent 74ef9ad5ca
commit dfc77b0350

View File

@@ -467,7 +467,7 @@ mod arena {
mod arena {
pub fn alloc(len: usize) -> *mut u8 {
let layout = std::alloc::Layout::from_size_align(len, std::mem::size_of::<u8>()).unwrap();
unsafe { std::alloc::alloc(layout) }
unsafe { std::alloc::alloc_zeroed(layout) }
}
pub fn dealloc(ptr: *mut u8, len: usize) {
let layout = std::alloc::Layout::from_size_align(len, std::mem::size_of::<u8>()).unwrap();