From dc6ce9a7d520c21be295001a7f406081ed4293ab Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Tue, 7 May 2024 18:33:09 +0200 Subject: [PATCH] fix memory counting without custom allocator (vercel/turbo#8102) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ### Description ### Testing Instructions Closes PACK-3044 --- crates/turbo-tasks-malloc/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/turbo-tasks-malloc/src/lib.rs b/crates/turbo-tasks-malloc/src/lib.rs index 768aa0333e89b..3e0d1462ef19a 100644 --- a/crates/turbo-tasks-malloc/src/lib.rs +++ b/crates/turbo-tasks-malloc/src/lib.rs @@ -42,7 +42,7 @@ unsafe impl GlobalAlloc for TurboMalloc { unsafe fn alloc_zeroed(&self, layout: Layout) -> *mut u8 { let ret = mimalloc::MiMalloc.alloc_zeroed(layout); - if ret.is_null() { + if !ret.is_null() { add(layout.size()); } ret @@ -82,7 +82,7 @@ unsafe impl GlobalAlloc for TurboMalloc { unsafe fn alloc_zeroed(&self, layout: Layout) -> *mut u8 { let ret = std::alloc::System.alloc_zeroed(layout); - if ret.is_null() { + if !ret.is_null() { add(layout.size()); } ret