libluna/Heap: Zero out newly created heap blocks
This commit is contained in:
parent
eaed109fe9
commit
7d045e45c1
@ -105,7 +105,9 @@ static Option<HeapBlock*> split(HeapBlock* block, usize size)
|
||||
const usize offset = get_fair_offset_to_split_at(block, size + sizeof(HeapBlock));
|
||||
block->full_size = offset; // shrink the old block to fit this offset
|
||||
|
||||
HeapBlock* new_block = offset_ptr(block, offset + sizeof(HeapBlock));
|
||||
HeapBlock* const new_block = offset_ptr(block, offset + sizeof(HeapBlock));
|
||||
|
||||
memset(new_block, 0, sizeof(*new_block));
|
||||
|
||||
new_block->magic = BLOCK_MAGIC;
|
||||
new_block->status = (block->status & BLOCK_END_MEM) ? BLOCK_END_MEM : 0;
|
||||
@ -212,6 +214,8 @@ Result<void*> malloc_impl(usize size, bool should_scrub)
|
||||
usize pages = get_pages_for_allocation(size + sizeof(HeapBlock));
|
||||
HeapBlock* const current = (HeapBlock*)TRY(allocate_pages_impl(pages));
|
||||
|
||||
memset(current, 0, sizeof(*current));
|
||||
|
||||
current->full_size = (pages * PAGE_SIZE) - sizeof(HeapBlock);
|
||||
current->magic = BLOCK_MAGIC;
|
||||
current->status = BLOCK_START_MEM | BLOCK_END_MEM;
|
||||
|
Loading…
Reference in New Issue
Block a user