1 parent 1db9be9 commit 657caf8Copy full SHA for 657caf8
1 file changed
tests/all/tests.rs
@@ -71,8 +71,13 @@ fn oom_instead_of_bump_pointer_overflow() {
71
let x = bump.alloc(0_u8);
72
let p = x as *mut u8 as usize;
73
74
+ // Prevent bump from allocating a new chunk.
75
+ bump.set_allocation_limit(Some(bump.allocated_bytes()));
76
+
77
// A size guaranteed to overflow the bump pointer.
- let size = (isize::MAX as usize) - p + 1;
78
+ // We assume that heap allocations are made in bottom half of address space, so `size < isize::MAX`.
79
+ // If that assumption is incorrect, `Layout::from_size_align` will return `Err` and the test will fail.
80
+ let size = p + 1;
81
let align = 1;
82
let layout = match Layout::from_size_align(size, align) {
83
Err(e) => {
0 commit comments