diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-01-23 07:32:16 +0100 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-01-23 07:32:16 +0100 |
commit | cfa197f821f23e668aa0c034ef6d25def6e32ed9 (patch) | |
tree | 17a8e13194d5506e266da7ee015113ec62d9bbed /LibC/stdlib.cpp | |
parent | 0ebaa35aa1d8ccc3f6c6ffc420b3c106a81e9709 (diff) | |
download | serenity-cfa197f821f23e668aa0c034ef6d25def6e32ed9.zip |
LibC: Let malloc(0) return nullptr.
Diffstat (limited to 'LibC/stdlib.cpp')
-rw-r--r-- | LibC/stdlib.cpp | 3 |
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); |