test that environ gets deallocated on changes
This commit is contained in:
parent
aedc34c6e5
commit
6eccc809f2
1 changed files with 10 additions and 0 deletions
10
tests/compile-fail/environ-gets-deallocated.rs
Normal file
10
tests/compile-fail/environ-gets-deallocated.rs
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
extern "C" {
|
||||
static environ: *const *const u8;
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let pointer = unsafe { environ };
|
||||
let _x = unsafe { *pointer };
|
||||
std::env::set_var("FOO", "BAR");
|
||||
let _y = unsafe { *pointer }; //~ ERROR dangling pointer was dereferenced
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue