Skip to content

Commit d2e3078

Browse files
#31 - Prevent overflow if not enough space
1 parent 63a5574 commit d2e3078

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

kernel/src/drivers/allocator.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ static void _defragment_block(MemoryHeader_t* header) {
9191
}
9292

9393
static void _fragment_block(MemoryHeader_t* header, uintptr_t size) {
94+
if (size > header->size) return;
9495
uintptr_t remaining_space = header->size - size;
9596
// if there isn't enough space for anything really
9697
if (remaining_space < sizeof(MemoryHeader_t) + MINIMUM_BLOCK_SIZE) {

0 commit comments

Comments
 (0)