diff options
author | Gunnar Beutner <gbeutner@serenityos.org> | 2021-05-27 21:07:56 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-05-27 21:13:57 +0200 |
commit | 97d0ebba20edb6afeb015801bec4f7305edf39a0 (patch) | |
tree | 166cb407d46cbabd1c9a58ec9deaef70b54b1ff0 | |
parent | 14585a9cba82df1359652f69f2fa91303bb49c75 (diff) | |
download | serenity-97d0ebba20edb6afeb015801bec4f7305edf39a0.zip |
LibJS: Make sure aligned_alloc() doesn't return a null pointer
The previous VERIFY() call checked that aligned_alloc() didn't return
MAP_FAILED. When out of memory aligned_alloc() returns a null pointer
so let's check for that instead.
-rw-r--r-- | Userland/Libraries/LibJS/Heap/BlockAllocator.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/Userland/Libraries/LibJS/Heap/BlockAllocator.cpp b/Userland/Libraries/LibJS/Heap/BlockAllocator.cpp index 1e50414b88..d622623385 100644 --- a/Userland/Libraries/LibJS/Heap/BlockAllocator.cpp +++ b/Userland/Libraries/LibJS/Heap/BlockAllocator.cpp @@ -38,10 +38,11 @@ void* BlockAllocator::allocate_block([[maybe_unused]] char const* name) #ifdef __serenity__ auto* block = (HeapBlock*)serenity_mmap(nullptr, HeapBlock::block_size, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_RANDOMIZED | MAP_PRIVATE, 0, 0, HeapBlock::block_size, name); + VERIFY(block != MAP_FAILED); #else auto* block = (HeapBlock*)aligned_alloc(HeapBlock::block_size, HeapBlock::block_size); + VERIFY(block); #endif - VERIFY(block != MAP_FAILED); return block; } |