mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-06 02:55:49 +03: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
Notes:
sideshowbarker
2024-07-18 07:00:52 +09:00
Author: https://github.com/BertalanD Commit: https://github.com/SerenityOS/serenity/commit/85ea66932e0 Pull-request: https://github.com/SerenityOS/serenity/pull/9376 Reviewed-by: https://github.com/alimpfard
@ -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…
Reference in New Issue
Block a user