From 1c899657c10b2564bc8e324cb1be54f8e907474c Mon Sep 17 00:00:00 2001 From: Daniel Micay Date: Sun, 14 Apr 2019 19:12:38 -0400 Subject: [PATCH] add is_init check to mallinfo functions --- h_malloc.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/h_malloc.c b/h_malloc.c index dedd0bb..d4be9ff 100644 --- a/h_malloc.c +++ b/h_malloc.c @@ -1698,6 +1698,10 @@ EXPORT struct mallinfo h_mallinfo(void) { // glibc mallinfo type definition and implementation are both broken #if CONFIG_STATS && !defined(__GLIBC__) + if (!is_init()) { + return info; + } + struct region_allocator *ra = ro.region_allocator; mutex_lock(&ra->lock); info.hblkhd += ra->allocated; @@ -1791,6 +1795,10 @@ EXPORT struct mallinfo __mallinfo_bin_info(UNUSED size_t arena, UNUSED size_t bi struct mallinfo info = {0}; #if CONFIG_STATS + if (!is_init()) { + return info; + } + if (arena < N_ARENA && bin < N_SIZE_CLASSES) { struct size_class *c = &ro.size_class_metadata[arena][bin];