mirror of
https://github.com/phil-opp/blog_os.git
synced 2025-12-16 22:37:49 +00:00
Fixes #220: BumpAllocator overflow
I also fixed a spelling error and replaced a tab with a space
in the blog post where `allocate()` was created.
(cherry picked from commit 54e02fd6b5)
(cherry picked from commit 3a2f0b33297164ebbfab92ee76881b6c06c4914d)
This commit is contained in:
committed by
Philipp Oppermann
parent
6e20fe17db
commit
258a7d1aba
@@ -35,7 +35,7 @@ impl BumpAllocator {
|
||||
/// Allocates a block of memory with the given size and alignment.
|
||||
fn allocate(&mut self, size: usize, align: usize) -> Option<*mut u8> {
|
||||
let alloc_start = align_up(self.next, align);
|
||||
let alloc_end = alloc_start + size;
|
||||
let alloc_end = alloc_start.saturating_add(size);
|
||||
|
||||
if alloc_end <= self.heap_start + self.heap_size {
|
||||
self.next = alloc_end;
|
||||
|
||||
Reference in New Issue
Block a user