Skip to content

Commit 6c44100

Browse files
cfsmp3claude
andcommitted
fix(rust): Handle NULL file pointer in ccxr_demuxer_open for UDP/TCP input
When using --udp or --tcp options, ccxr_demuxer_open() was called with a NULL file pointer, causing a crash in CStr::from_ptr(). The fix checks if the file pointer is NULL before dereferencing it, and uses an empty string for network input modes. Fixes CCExtractor#1846 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 2060db9 commit 6c44100

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)