From d1b84ee0a2f08712db0166453a14b60570192ad0 Mon Sep 17 00:00:00 2001 From: Julian Orth Date: Fri, 18 Jul 2025 23:28:23 +0200 Subject: [PATCH] leaks: properly align allocations --- src/leaks.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/leaks.rs b/src/leaks.rs index 211d3933..da3ad06f 100644 --- a/src/leaks.rs +++ b/src/leaks.rs @@ -272,7 +272,8 @@ mod leaks { unsafe impl GlobalAlloc for TracingAllocator { unsafe fn alloc(&self, layout: Layout) -> *mut u8 { unsafe { - let res = c::calloc(layout.size(), 1) as *mut u8; + let res = c::aligned_alloc(layout.align(), layout.size()) as *mut u8; + c::memset(res.cast(), 0, layout.size()); if IN_ALLOCATOR.get() == 0 { IN_ALLOCATOR.set(1); ALLOCATIONS.get().deref_mut().insert(