|
|
|
|
|
by anderskaseorg
588 days ago
|
|
Yes, allowing this to execute would be very unsound: let lock = RwLock::new(Box::new(111));
let r: &i32 = &**lock.read().unwrap(); // points to 111
*lock.write().unwrap() = Box::new(222); // allocates a new Box and deallocates 111
println!("{}", *r); // use after free
|
|