2018-10-12 03:54:37 -05:00
|
|
|
// This should fail even without validation
|
2018-10-24 10:17:44 -05:00
|
|
|
// compile-flags: -Zmiri-disable-validation
|
2018-10-12 03:54:37 -05:00
|
|
|
|
2018-07-31 13:27:36 -05:00
|
|
|
static mut LEAK: usize = 0;
|
|
|
|
|
|
|
|
fn fill(v: &mut i32) {
|
|
|
|
unsafe { LEAK = v as *mut _ as usize; }
|
|
|
|
}
|
|
|
|
|
|
|
|
fn evil() {
|
2019-07-28 11:08:39 -05:00
|
|
|
unsafe { &mut *(LEAK as *mut i32) }; //~ ERROR dangling pointer was dereferenced
|
2018-07-31 13:27:36 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let _y;
|
|
|
|
{
|
|
|
|
let mut x = 0i32;
|
|
|
|
fill(&mut x);
|
|
|
|
_y = x;
|
|
|
|
}
|
|
|
|
evil();
|
|
|
|
}
|