diff options
author | Daniel Bertalan <dani@danielbertalan.dev> | 2021-07-12 19:17:41 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-07-14 13:12:25 +0200 |
commit | b847541ee8566d5d90af6b49476a32351e2b11d6 (patch) | |
tree | e44b2079e3b75d31f62202e4bd887f91a97ff055 /Kernel/Heap | |
parent | bb26cea2910c051edbcaf0e20aaa22c9325faf8f (diff) | |
download | serenity-b847541ee8566d5d90af6b49476a32351e2b11d6.zip |
Kernel: Allow passing null pointer to delete
The C++ standard says that it's legal to call the `delete` operator with
a null pointer argument, in which case it should be a no-op. I
encountered this issue when running a kernel that's compiled with Clang.
I assume this fact was used for some kind of optimization.
Diffstat (limited to 'Kernel/Heap')
-rw-r--r-- | Kernel/Heap/SlabAllocator.h | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/Kernel/Heap/SlabAllocator.h b/Kernel/Heap/SlabAllocator.h index bfaa2c99e1..5650d428c1 100644 --- a/Kernel/Heap/SlabAllocator.h +++ b/Kernel/Heap/SlabAllocator.h @@ -33,6 +33,8 @@ public: \ } \ void operator delete(void* ptr) noexcept \ { \ + if (!ptr) \ + return; \ slab_dealloc(ptr, sizeof(type)); \ } \ \ |