jkcoxson / rusty_libimobiledevice

A Rust wrapper for Libimobiledevice
MIT License
44 stars 19 forks source link

Fix passing strings to C #12

Closed michaelwright235 closed 1 month ago

michaelwright235 commented 1 month ago

Passing Rust strings to the C side is not always correctly done. There are some cases, when a pointer to a Rust string gets passed, however it must be converted to a CString first. Also a CString must be bound a local variable before calling as_ptr method, or else it gets deallocated and a pointer gets invalid. I’ve also refactored some related code to make it more consistent.

jkcoxson commented 1 month ago

Wow! That's a lot of work, thank you so much! All the changes you made look appropriate, although I currently don't have a device to test your code that you wrote the TODO above for segfaults.