*: fix UB with CString usage

This commit is contained in:
meh
2015-09-22 02:44:13 +02:00
parent 9ab5841b55
commit 2ca44d08d4
6 changed files with 53 additions and 20 deletions

View File

@ -90,7 +90,9 @@ impl From<AVSampleFormat> for Sample {
impl From<&'static str> for Sample {
fn from(value: &'static str) -> Self {
unsafe {
Sample::from(av_get_sample_fmt(CString::new(value).unwrap().as_ptr()))
let value = CString::new(value).unwrap();
Sample::from(av_get_sample_fmt(value.as_ptr()))
}
}
}