summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Kernel/Heap/SlabAllocator.h2
-rw-r--r--Kernel/KString.cpp2
2 files changed, 4 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)); \
} \
\
diff --git a/Kernel/KString.cpp b/Kernel/KString.cpp
index 201554938d..da5c3bf76c 100644
--- a/Kernel/KString.cpp
+++ b/Kernel/KString.cpp
@@ -59,6 +59,8 @@ OwnPtr<KString> KString::try_clone() const
void KString::operator delete(void* string)
{
+ if (!string)
+ return;
size_t allocation_size = sizeof(KString) + (sizeof(char) * static_cast<KString*>(string)->m_length) + sizeof(char);
kfree_sized(string, allocation_size);
}