mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-26 09:30:24 +00:00
Kernel: Refuse to allocate 0 bytes of virtual address space
This commit is contained in:
parent
26fb3f7269
commit
a87544fe8b
Notes:
sideshowbarker
2024-07-19 09:12:51 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/a87544fe8b3
1 changed files with 6 additions and 0 deletions
|
@ -96,6 +96,9 @@ void RangeAllocator::carve_at_index(int index, const Range& range)
|
|||
|
||||
Range RangeAllocator::allocate_anywhere(size_t size, size_t alignment)
|
||||
{
|
||||
if (!size)
|
||||
return {};
|
||||
|
||||
#ifdef VM_GUARD_PAGES
|
||||
// NOTE: We pad VM allocations with a guard page on each side.
|
||||
size_t effective_size = size + PAGE_SIZE * 2;
|
||||
|
@ -135,6 +138,9 @@ Range RangeAllocator::allocate_anywhere(size_t size, size_t alignment)
|
|||
|
||||
Range RangeAllocator::allocate_specific(VirtualAddress base, size_t size)
|
||||
{
|
||||
if (!size)
|
||||
return {};
|
||||
|
||||
Range allocated_range(base, size);
|
||||
for (int i = 0; i < m_available_ranges.size(); ++i) {
|
||||
auto& available_range = m_available_ranges[i];
|
||||
|
|
Loading…
Reference in a new issue