blob: 84618abc6dbbace6cb41949698209b77f67bc646 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
//@ignore-target: windows # Windows does not have a global environ list that the program can access directly
fn get_environ() -> *const *const u8 {
extern "C" {
static mut environ: *const *const u8;
}
unsafe { environ }
}
fn main() {
let pointer = get_environ();
let _x = unsafe { *pointer };
std::env::set_var("FOO", "BAR");
let _y = unsafe { *pointer }; //~ ERROR: has been freed
}
|