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:
Calvin Lee
2016-09-22 12:25:59 -06:00
committed by Philipp Oppermann
parent 19f0b5443a
commit 30a75ec760

View File

@@ -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;