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.
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.
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.