Skip to content

Commit 7f92eab

Browse files
committed
Add test to exercise InvalidUndefBytes
1 parent d9ac84d commit 7f92eab

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// error-pattern: reading uninitialized memory
2+
3+
use std::alloc::{alloc, dealloc, Layout};
4+
use std::slice::from_raw_parts;
5+
6+
fn main() {
7+
let layout = Layout::from_size_align(32, 8).unwrap();
8+
unsafe {
9+
let ptr = alloc(layout);
10+
*ptr = 0x41;
11+
*ptr.add(1) = 0x42;
12+
*ptr.add(2) = 0x43;
13+
*ptr.add(3) = 0x44;
14+
*ptr.add(16) = 0x00;
15+
let slice1 = from_raw_parts(ptr, 16);
16+
let slice2 = from_raw_parts(ptr.add(16), 16);
17+
drop(slice1.cmp(slice2));
18+
dealloc(ptr, layout);
19+
}
20+
}

0 commit comments

Comments
 (0)