Skip to content

Conversation

@cfsmp3
Copy link
Contributor

@cfsmp3 cfsmp3 commented Dec 19, 2025

Summary

Fixes #1846

When using --udp or --tcp options, ccxr_demuxer_open() was called with a NULL file pointer, causing a crash in CStr::from_ptr().

Root Cause

The Rust FFI function ccxr_demuxer_open assumed the file parameter was always a valid C string pointer:

let c_str = CStr::from_ptr(file);  // Crashes if file is NULL

For network input modes (UDP/TCP), the C code passes NULL since there's no file to open.

Fix

Check if the file pointer is NULL before dereferencing:

let file_str = if !file.is_null() {
    match CStr::from_ptr(file).to_str() {
        Ok(s) => s,
        Err(_) => return -1,
    }
} else {
    ""
};

Testing

Verified both UDP and TCP modes work:

# UDP - confirmed listening with ss
$ timeout 10 ./ccextractor --udp 54321 &
$ ss -ulnp | grep 54321
UNCONN 0 0 0.0.0.0:54321 0.0.0.0:* users:(("ccextractor",pid=99942,fd=4))

# TCP - confirmed listening
$ timeout 10 ./ccextractor --tcp 54322 &
$ ss -tlnp | grep 54322
LISTEN 0 128 *:54322 *:* users:(("ccextractor",pid=98972,fd=4))

Test Plan

  • Build succeeds
  • UDP mode starts and listens on specified port
  • TCP mode starts and listens on specified port
  • No crash on startup

🤖 Generated with Claude Code

…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 #1846

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@ccextractor-bot
Copy link
Collaborator

CCExtractor CI platform finished running the test files on linux. Below is a summary of the test results, when compared to test for commit 138ccd0...:
Report Name Tests Passed
Broken 9/13
CEA-708 8/14
DVB 6/7
DVD 0/3
DVR-MS 2/2
General 4/27
Hardsubx 0/1
Hauppage 0/3
MP4 3/3
NoCC 10/10
Options 72/86
Teletext 20/21
WTV 9/13
XDS 13/34

Your PR breaks these cases:

NOTE: The following tests have been failing on the master branch as well as the PR:

Congratulations: Merging this PR would fix the following tests:

  • ccextractor --autoprogram --out=ttxt --latin1 1974a299f0..., Last passed: Never
  • ccextractor --autoprogram --out=ttxt --latin1 --ucla dab1c1bd65..., Last passed: Never
  • ccextractor --out=srt --latin1 --autoprogram 29e5ffd34b..., Last passed: Never
  • ccextractor --startcreditstext "CCextractor Start crdit Testing" c4dd893cb9..., Last passed: Never
  • ccextractor --startcreditsnotbefore 1 --startcreditstext "CCextractor Start crdit Testing" c4dd893cb9..., Last passed: Never
  • ccextractor --startcreditsnotafter 2 --startcreditstext "CCextractor Start crdit Testing" c4dd893cb9..., Last passed: Never
  • ccextractor --startcreditsforatleast 1 --startcreditstext "CCextractor Start crdit Testing" c4dd893cb9..., Last passed: Never
  • ccextractor --startcreditsforatmost 2 --startcreditstext "CCextractor Start crdit Testing" c4dd893cb9..., Last passed: Never

It seems that not all tests were passed completely. This is an indication that the output of some files is not as expected (but might be according to you).

Check the result page for more info.

@cfsmp3 cfsmp3 merged commit c3f637a into master Dec 19, 2025
29 of 31 checks passed
@ccextractor-bot
Copy link
Collaborator

CCExtractor CI platform finished running the test files on windows. Below is a summary of the test results, when compared to test for commit a0593c6...:
Report Name Tests Passed
Broken 12/13
CEA-708 8/14
DVB 7/7
DVD 3/3
DVR-MS 2/2
General 27/27
Hardsubx 0/1
Hauppage 3/3
MP4 3/3
NoCC 10/10
Options 82/86
Teletext 21/21
WTV 12/13
XDS 26/34

NOTE: The following tests have been failing on the master branch as well as the PR:

Congratulations: Merging this PR would fix the following tests:

  • ccextractor --out=srt --latin1 611b4a9235..., Last passed: Never
  • ccextractor --autoprogram --out=ttxt --latin1 9a496d3828..., Last passed: Never
  • ccextractor --autoprogram --out=ttxt --latin1 c032183ef0..., Last passed: Never
  • ccextractor --autoprogram --out=ttxt --latin1 27e46255f0..., Last passed: Never
  • ccextractor --autoprogram --out=ttxt --latin1 132d7df7e9..., Last passed: Never
  • ccextractor --autoprogram --out=ttxt --latin1 99e5eaafdc..., Last passed: Never
  • ccextractor --autoprogram --out=ttxt --latin1 --ucla 5d3a29f9f8..., Last passed: Never
  • ccextractor --autoprogram --out=ttxt --latin1 --ucla 70000200c0..., Last passed: Never
  • ccextractor --autoprogram --out=ttxt --latin1 --ucla 15feae9133..., Last passed: Never
  • ccextractor --autoprogram --out=ttxt --latin1 --ucla 95dd33c6f1..., Last passed: Never
  • ccextractor --autoprogram --out=ttxt --latin1 --ucla --output-field 2 5d3a29f9f8..., Last passed: Never
  • ccextractor --autoprogram --out=ttxt --hauppauge --ucla --latin1 553d78e755..., Last passed: Never
  • ccextractor --in=bin 988d4e8bba..., Last passed: Never
  • ccextractor --out=srt --latin1 f23a544ba8..., Last passed: Never
  • ccextractor --out=srt --latin1 97cc394d87..., Last passed: Never
  • ccextractor --out=srt --latin1 76734ac4a7..., Last passed: Never
  • ccextractor --out=srt --latin1 c791382c94..., Last passed: Never
  • ccextractor --out=srt --latin1 f673b2f916..., Last passed: Never
  • ccextractor --out=srt --latin1 da75bdee47..., Last passed: Never
  • ccextractor --out=srt --latin1 bd6f33a669..., Last passed: Never
  • ccextractor --out=srt --latin1 a226cc302d..., Last passed: Never
  • ccextractor --out=srt --latin1 ae6327683e..., Last passed: Never
  • ccextractor --autoprogram --out=ttxt --latin1 --ucla --xds 725a49f871..., Last passed: Never
  • ccextractor --autoprogram --out=ttxt --xds --latin1 --ucla e274a73653..., Last passed: Never
  • ccextractor --autoprogram --out=ttxt --latin1 --ucla --xds b22260d065..., Last passed: Never
  • ccextractor --autoprogram --out=ttxt --latin1 --xds --ucla c813e713a0..., Last passed: Never
  • ccextractor --autoprogram --out=ttxt --latin1 --ucla --xds 27fab4dbb6..., Last passed: Never
  • ccextractor --autoprogram --out=ttxt --latin1 --ucla --xds bbd5bb52fc..., Last passed: Never
  • ccextractor --autoprogram --out=ttxt --latin1 --ucla 7d2730d38e..., Last passed: Never
  • ccextractor --autoprogram --out=ttxt --latin1 --ucla --xds 88cd42b89a..., Last passed: Never
  • ccextractor --autoprogram --out=ttxt --latin1 --ucla --xds 7f41299cc7..., Last passed: Never

All tests passing on the master branch were passed completely.

Check the result page for more info.

@cfsmp3 cfsmp3 deleted the fix/issue-1846-udp-tcp-crash branch December 20, 2025 07:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] UDP and TCP dies at the master HEAD

3 participants