From 545180cad017845d78c93f76daa6e8bf2ec1b764 Mon Sep 17 00:00:00 2001 From: Zhiming Wang Date: Tue, 11 Aug 2020 00:30:58 +0800 Subject: [PATCH] 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. --- src/format/context/input.rs | 3 +-- src/format/context/output.rs | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/format/context/input.rs b/src/format/context/input.rs index 871b527..55e491a 100644 --- a/src/format/context/input.rs +++ b/src/format/context/input.rs @@ -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, ); } diff --git a/src/format/context/output.rs b/src/format/context/output.rs index ceb1ec9..08bf20d 100644 --- a/src/format/context/output.rs +++ b/src/format/context/output.rs @@ -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, ); }