rust-pkcs11
rust-pkcs11 copied to clipboard
Fix use-after-free bug in Ctx::initialize
Previously, init_args was being destructured by value, causing it to be dropped before C_Initialize was called. This caused undefined behavior. I believe this fixes #49.
The fact that a bug in safe code caused this is a bit worrying. In my opinion, all the function pointers in CK_FUNCTION_LIST
should be marked as unsafe, and have safe wrappers that take references rather than raw pointers.