format: context::{input,output}::dump: fix url/path printing

Previously the unwrapped CString did not have long enough lifetime to be
printed; not sure why there's no compiler warning.
This commit is contained in:
Zhiming Wang 2020-08-11 00:30:58 +08:00
parent f024eaea37
commit 545180cad0
No known key found for this signature in database
GPG Key ID: 5B58F95EC95965D8
2 changed files with 2 additions and 3 deletions

View File

@ -1,7 +1,6 @@
use std::ffi::CString;
use std::mem;
use std::ops::{Deref, DerefMut};
use std::ptr;
use super::common::Context;
use super::destructor;
@ -183,7 +182,7 @@ pub fn dump(ctx: &Input, index: i32, url: Option<&str>) {
av_dump_format(
ctx.as_ptr() as *mut _,
index,
url.map(|u| u.as_ptr()).unwrap_or(ptr::null()),
url.unwrap_or_else(|| CString::new("").unwrap()).as_ptr(),
0,
);
}

View File

@ -174,7 +174,7 @@ pub fn dump(ctx: &Output, index: i32, url: Option<&str>) {
av_dump_format(
ctx.as_ptr() as *mut _,
index,
url.map(|u| u.as_ptr()).unwrap_or(ptr::null()),
url.unwrap_or_else(|| CString::new("").unwrap()).as_ptr(),
1,
);
}