nagisa / rust_libloading

Bindings around the platform's dynamic library loading primitives with greatly improved memory safety.
https://docs.rs/libloading
ISC License
1.24k stars 102 forks source link

`Deref` in `Symbol` can leak a raw function pointer. #158

Closed lvella closed 1 month ago

lvella commented 1 month ago

I can just take a Symbol, deref into a &T, clone the function pointer T, and boom, I am completely free from the 'lib lifetime.

Considering function pointers always have 'static lifetime, I don't think there is any safe alternative for this problem. Maybe manually implement Fn trait? But this is unstable.

nagisa commented 1 month ago

Duplicate of https://github.com/nagisa/rust_libloading/issues/13