uniffi-rs
uniffi-rs copied to clipboard
`HandleAlloc::clone_handle` and `consume_handle` should be marked unsafe
The clone_handle and consume_handle methods in the HandleAlloc trait should be unsafe:
https://github.com/mozilla/uniffi-rs/blob/cd38ccea8236df7d93aff336c325a3a8e524af5d/uniffi_core/src/ffi_converter_traits.rs#L629-L637
The problem is that you can create a Handle with any u64 value you want in safe Rust:
let h = Handle::from_raw(42);
h.clone_handle(); // calls the unsafe Arc::increment_strong_count on 42
I discussed this with @badboy at RustFest and there is a chance that none of the generated bindings code ever calls it like that. If so, then it should be possible to add unsafe to the trait methods and propagate this upwards.