Skip to content

Commit c3f637a

Browse files
authored
fix(rust): Handle NULL file pointer in ccxr_demuxer_open for UDP/TCP input
2 parents f376862 + 6c44100 commit c3f637a

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/rust/src/libccxr_exports/demuxer.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -427,10 +427,15 @@ pub unsafe extern "C" fn ccxr_demuxer_open(ctx: *mut ccx_demuxer, file: *const c
427427
if ctx.is_null() {
428428
return -1;
429429
}
430-
let c_str = CStr::from_ptr(file);
431-
let file_str = match c_str.to_str() {
432-
Ok(s) => s,
433-
Err(_) => return -1,
430+
431+
// Handle NULL file pointer (e.g., when using --udp or --tcp network input)
432+
let file_str = if !file.is_null() {
433+
match CStr::from_ptr(file).to_str() {
434+
Ok(s) => s,
435+
Err(_) => return -1,
436+
}
437+
} else {
438+
""
434439
};
435440

436441
let mut demux_ctx = copy_demuxer_from_c_to_rust(ctx);

0 commit comments

Comments
 (0)