2018-10-12 10:54:37 +02:00
|
|
|
// This should fail even without validation
|
2018-10-24 17:17:44 +02:00
|
|
|
// compile-flags: -Zmiri-disable-validation
|
2018-10-12 10:54:37 +02:00
|
|
|
|
2018-07-31 20:27:36 +02:00
|
|
|
static mut LEAK: usize = 0;
|
|
|
|
|
|
|
|
fn fill(v: &mut i32) {
|
|
|
|
unsafe { LEAK = v as *mut _ as usize; }
|
|
|
|
}
|
|
|
|
|
|
|
|
fn evil() {
|
2020-03-08 23:34:54 +01:00
|
|
|
unsafe { &mut *(LEAK as *mut i32) }; //~ ERROR dereferenced after this allocation got freed
|
2018-07-31 20:27:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let _y;
|
|
|
|
{
|
|
|
|
let mut x = 0i32;
|
|
|
|
fill(&mut x);
|
|
|
|
_y = x;
|
|
|
|
}
|
|
|
|
evil();
|
|
|
|
}
|