From ff952fa2e43de1c194ed9ecf562939ee106eddd0 Mon Sep 17 00:00:00 2001 From: apio Date: Sun, 20 Nov 2022 18:04:29 +0100 Subject: [PATCH] Confirm alignment when calculating an offset to split at --- kernel/src/memory/Heap.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/kernel/src/memory/Heap.cpp b/kernel/src/memory/Heap.cpp index ac1b9bcd..74866481 100644 --- a/kernel/src/memory/Heap.cpp +++ b/kernel/src/memory/Heap.cpp @@ -85,6 +85,9 @@ static usize get_fair_offset_to_split_at(HeapBlock* block, usize min) available -= (available / 2); // reserve half of the rest for the new block, while still leaving another half for the old one. + check(is_aligned(available, + 16UL)); // If necessary, we can just align it. This is more of a sanity check than a requirement. + return available + block->req_size; }