From e26d4a4ddbdf5843eff51df2e491f085fa8fe280 Mon Sep 17 00:00:00 2001 From: vblanco20-1 <1417000+vblanco20-1@users.noreply.github.com> Date: Tue, 26 Sep 2023 11:46:11 +0200 Subject: [PATCH] Fixing bug where allocating a new arena would not zero memory correctly --- src/arena.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/arena.c b/src/arena.c index a04a04c8..51c5a4c9 100644 --- a/src/arena.c +++ b/src/arena.c @@ -179,7 +179,11 @@ static void* mi_arena_meta_zalloc(size_t size, mi_memid_t* memid, mi_stats_t* st if (p != NULL) return p; // or fall back to the OS - return _mi_os_alloc(size, memid, stats); + p = _mi_os_alloc(size,memid,stats); + if (p != NULL && !memid->initially_zero) { + _mi_memzero(p,size); + } + return p; } static void mi_arena_meta_free(void* p, mi_memid_t memid, size_t size, mi_stats_t* stats) {