summaryrefslogtreecommitdiff
path: root/LibC/stdlib.cpp
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-01-23 07:32:16 +0100
committerAndreas Kling <awesomekling@gmail.com>2019-01-23 07:32:16 +0100
commitcfa197f821f23e668aa0c034ef6d25def6e32ed9 (patch)
tree17a8e13194d5506e266da7ee015113ec62d9bbed /LibC/stdlib.cpp
parent0ebaa35aa1d8ccc3f6c6ffc420b3c106a81e9709 (diff)
downloadserenity-cfa197f821f23e668aa0c034ef6d25def6e32ed9.zip
LibC: Let malloc(0) return nullptr.
Diffstat (limited to 'LibC/stdlib.cpp')
-rw-r--r--LibC/stdlib.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/LibC/stdlib.cpp b/LibC/stdlib.cpp
index 4be45c7d2f..671f6517cc 100644
--- a/LibC/stdlib.cpp
+++ b/LibC/stdlib.cpp
@@ -42,6 +42,9 @@ static uint32_t s_malloc_sum_free = POOL_SIZE;
void* malloc(size_t size)
{
+ if (size == 0)
+ return nullptr;
+
// We need space for the MallocHeader structure at the head of the block.
size_t real_size = size + sizeof(MallocHeader) + sizeof(MallocFooter);