Skip to content

Commit 9f13866

Browse files
authored
Merge pull request #110 from jamesmunns/james/fix-ub
Don't create an intermediate `&[u8]` when initializing Tlsf alloc
2 parents 83157f6 + fa3950c commit 9f13866

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/tlsf.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,9 @@ impl Heap {
6161
let mut heap = self.heap.borrow_ref_mut(cs);
6262
assert!(!heap.1);
6363
heap.1 = true;
64-
let block: &[u8] = core::slice::from_raw_parts(start_addr as *const u8, size);
65-
heap.0.insert_free_block_ptr(block.into());
64+
let block: NonNull<[u8]> =
65+
NonNull::slice_from_raw_parts(NonNull::new_unchecked(start_addr as *mut u8), size);
66+
heap.0.insert_free_block_ptr(block);
6667
});
6768
}
6869

0 commit comments

Comments
 (0)