From 74a4685ba9bc2b30950b1b44b7d3ee638ff84871 Mon Sep 17 00:00:00 2001 From: Alex Date: Fri, 28 Oct 2022 08:49:52 +0300 Subject: [PATCH] Clear new allocated memory --- Core/Memory/Memory.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/Core/Memory/Memory.cpp b/Core/Memory/Memory.cpp index 044a633..a8b2bcf 100644 --- a/Core/Memory/Memory.cpp +++ b/Core/Memory/Memory.cpp @@ -192,7 +192,11 @@ void *HeapMalloc(uint64_t Size) case MemoryAllocatorType::XallocV1: return XallocV1Allocator->Malloc(Size); case MemoryAllocatorType::liballoc11: - return PREFIX(malloc)(Size); + { + void *ret = PREFIX(malloc)(Size); + memset(ret, 0, Size); + return ret; + } default: throw; } @@ -207,7 +211,11 @@ void *HeapCalloc(uint64_t n, uint64_t Size) case MemoryAllocatorType::XallocV1: return XallocV1Allocator->Calloc(n, Size); case MemoryAllocatorType::liballoc11: - return PREFIX(calloc)(n, Size); + { + void *ret = PREFIX(calloc)(n, Size); + memset(ret, 0, Size); + return ret; + } default: throw; } @@ -222,7 +230,11 @@ void *HeapRealloc(void *Address, uint64_t Size) case MemoryAllocatorType::XallocV1: return XallocV1Allocator->Realloc(Address, Size); case MemoryAllocatorType::liballoc11: - return PREFIX(realloc)(Address, Size); + { + void *ret = PREFIX(realloc)(Address, Size); + memset(ret, 0, Size); + return ret; + } default: throw; }