Skip to content

Commit dbe0f1f

Browse files
committed
dangling-ptr-to-int should work now
1 parent b75e917 commit dbe0f1f

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

tests/run-pass/malloc.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@ fn main() {
1212
let saw_unaligned = (0..64).any(|_| unsafe {
1313
let p = libc::malloc(3);
1414
let addr = p as usize;
15-
let unaligned = addr % 4 != 0; // test that this is not 4-aligned
16-
libc::free(p); // FIXME have to free *after* test; should allow ptr-to-int of dangling ptr.
17-
unaligned
15+
libc::free(p);
16+
(p as usize) % 4 != 0 // find any that this is *not* 4-aligned
1817
});
1918
assert!(saw_unaligned);
2019

0 commit comments

Comments
 (0)