Skip to content

Commit 6b21c5f

Browse files
committed
remove memory leak from run-pass test
1 parent 0256c4d commit 6b21c5f

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

tests/run-pass/option_box_transmute_ptr.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ fn option_box_deref() -> i32 {
33
let val = Some(Box::new(42));
44
unsafe {
55
let ptr: *const i32 = std::mem::transmute::<Option<Box<i32>>, *const i32>(val);
6-
*ptr
6+
let ret = *ptr;
7+
// unleak memory
8+
std::mem::transmute::<*const i32, Option<Box<i32>>>(ptr);
9+
ret
710
}
811
}
912

0 commit comments

Comments
 (0)