Created
April 6, 2014 02:18
-
-
Save SiegeLord/10000695 to your computer and use it in GitHub Desktop.
Double free
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use std::cast; | |
| use std::libc::{c_void, malloc, free}; | |
| struct A | |
| { | |
| a: *mut c_void | |
| } | |
| impl Drop for A | |
| { | |
| fn drop(&mut self) | |
| { | |
| println!("drop"); | |
| unsafe | |
| { | |
| free(self.a); | |
| } | |
| } | |
| } | |
| impl A | |
| { | |
| fn new() -> A | |
| { | |
| unsafe | |
| { | |
| A{ a: malloc(10) } | |
| } | |
| } | |
| fn bloop(self) -> A | |
| { | |
| A{ a: self.a } | |
| } | |
| } | |
| fn main() | |
| { | |
| let a = A::new(); | |
| let b = a.bloop(); | |
| println!("Here"); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment