Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions src/rust/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,11 +255,18 @@ pub unsafe fn copy_from_rust(ccx_s_options: *mut ccx_s_options, options: Options
// Subsequent calls from ccxr_demuxer_open/close should NOT modify inputfile because
// C code holds references to those strings throughout processing.
// Freeing them would cause use-after-free and double-free errors.
if let Some(ref inputfile) = options.inputfile {
if let Some(ref _inputfile) = options.inputfile {
if (*ccx_s_options).inputfile.is_null() {
(*ccx_s_options).inputfile = string_to_c_chars(inputfile.clone());
(*ccx_s_options).num_input_files =
inputfile.iter().filter(|s| !s.is_empty()).count() as _;
let non_empty: Vec<String> = options
.inputfile
.as_ref()
.unwrap()
.iter()
.filter(|s| !s.is_empty())
.cloned()
.collect();
(*ccx_s_options).num_input_files = non_empty.len() as _;
(*ccx_s_options).inputfile = string_to_c_chars(non_empty);
}
}
(*ccx_s_options).demux_cfg = options.demux_cfg.to_ctype();
Expand Down
Loading