Skip to content

Instantly share code, notes, and snippets.

@rust-play
Created September 17, 2019 12:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rust-play/baa22bd36ef77fb1b612f8bcc1a72451 to your computer and use it in GitHub Desktop.
Save rust-play/baa22bd36ef77fb1b612f8bcc1a72451 to your computer and use it in GitHub Desktop.
Code shared from the Rust Playground
fn main() {
let raw_vec: *mut Vec<i32>;
{
let mut my_vec = vec![1, 2, 3, 4, 5];
raw_vec = &mut my_vec as *mut Vec<i32>;
}
// Example use of leaked pointer
unsafe { println!("{:?}", *raw_vec); }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment