rust-objc
rust-objc copied to clipboard
Unsound drop of uninitialised variable in Object::set_ivar.
There needs to be a way to initialize values, probably just calling ptr::write.
I never considered that someone might keep types that implement Drop in ivars! @quadrupleslap can you tell me more about your use case? I'm not sure how you'd plan to drop them (implement dealloc?) and what new APIs that would require.
The easy way to fix the unsoundness would be just adding a : Copy bound, but if you want to store Drop types that still doesn't help you 😛
I was trying to set some boxed values, but it's fine - it's not essential. Adding a Copy requirement sounds like a good idea, but I'm not sure if it's better than just adding Object::init_ivar, and adding a notice to the other *_ivar methods that the value might be uninitialized and that the user should call init_ivar first. The problem with that is that it doesn't automatically free the values, which is technically sound, but not very nice.