Skip to content

Commit fdefac8

Browse files
committed
Fix calloc test
Forgot to free the memory. Miri found the bug :)
1 parent fa0755c commit fdefac8

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

tests/run-pass/calloc.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ fn main() {
1717
let p3 = libc::calloc(0, 20);
1818
assert!(p3.is_null());
1919

20-
let p4 = libc::calloc(4, 8) as *const u8;
20+
let p4 = libc::calloc(4, 8);
2121
assert!(!p4.is_null());
22-
23-
let slice = slice::from_raw_parts(p4, 4 * 8);
22+
let slice = slice::from_raw_parts(p4 as *const u8, 4 * 8);
2423
assert_eq!(&slice, &[0_u8; 4 * 8]);
24+
libc::free(p4);
2525
}
2626
}

0 commit comments

Comments
 (0)