ebassi / taglib-rust

TagLib bindings for Rust
MIT License
27 stars 11 forks source link

Fix CString usages #3

Closed fabian-z closed 7 years ago

fabian-z commented 7 years ago

Current CString usage appears to be incorrect and passes dangling pointers to invalid / undefined memory regions. Without these changes, taglib effectively writes nothing or only random memory garbage for me.

Fixed according to the warning in the CString docs for as_ptr(), where the current let s = CString::new(title).unwrap().as_ptr(); style is given as an example for wrong CString usage.

This should supersede #2.

francesco-cattoglio commented 7 years ago

taglib-rust fails to even open files correctly for me, because the filename passed to taglib as a C string is random memory garbage. Applying this patch makes everything work properly.

ebassi commented 7 years ago

Thanks for the PR, and sorry for taking this much time to merge it.