mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 18:47:34 +00:00
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.
This commit is contained in:
parent
14585a9cba
commit
97d0ebba20
1 changed files with 2 additions and 1 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue