mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 06:47:34 +00:00
Kernel: Allow kfree_aligned
to be called on null pointers
The C++ standard specifies that `free` and `operator delete` should be callable with nullptr. The non-aligned `kfree` already handles this, but because of the pointer arithmetic to obtain the allocation start pointer, the aligned version would produce undefined behavior.
This commit is contained in:
parent
5c7524b1d8
commit
85ea66932e
1 changed files with 2 additions and 0 deletions
|
@ -93,6 +93,8 @@ template<size_t ALIGNMENT>
|
|||
|
||||
inline void kfree_aligned(void* ptr)
|
||||
{
|
||||
if (ptr == nullptr)
|
||||
return;
|
||||
kfree((u8*)ptr - ((const ptrdiff_t*)ptr)[-1]);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue