From 7ebc328b5ac9158dc52cc7809d4c19d2d9a33594 Mon Sep 17 00:00:00 2001 From: karutoh Date: Thu, 8 Feb 2024 18:51:44 -0800 Subject: [PATCH] fixed get_heap_size function by adding null pointer checks. --- main.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/main.c b/main.c index dc86001..ccfe0b0 100644 --- a/main.c +++ b/main.c @@ -157,6 +157,9 @@ void free(void* ptr) /// @returns Usage in bytes. size_t get_heap_size() { + if (!first || !last) + return 0; + return ((char*)last + last->size) - (char*)first; }