3 ms·
My problem was that I was taking a: Some([u8; 32]).map(|v| v.as_ptr()).unwrap_or(::std::ptr::null()); Which the map(..) copies by value and immediately goes
by vvanders 10y ago
My problem was that I was taking a:
Some([u8; 32]).map(|v| v.as_ptr()).unwrap_or(::std::ptr::null());
Which the map(..) copies by value and immediately goes out of scope so now you have a dangling pointer to the stack(fun!). If it was a reference I'd be totally covered but since pointers drop lifetime semantics that's where I got bit.
Love bindgen though, just whitelisting the function I needs generates awesome interop APIs. At the end of the day though unsafe is unsafe.
- Manishearth 10y agoah, yeah, bad idea :) Yep, unsafe is unsafe and needs more scrutiny.