Closed
Description
This code will segfault running drop glue for Box<Box<Fn()>>
, even though a value of that type is not actually created.
enum Handler {
Default,
Custom(*mut Box<Fn()>),
}
fn main() {
take();
}
fn take() -> Box<Fn()> {
unsafe {
match Handler::Default {
Handler::Default => Box::new(main),
Handler::Custom(ptr) => *Box::from_raw(ptr),
}
}
}
Interestingly, it exits successfully if the second match body is wrapped in a block.