Skip to content

[FIX] Add NULL check for strdup() return value in matroska.c#2204

Closed
aparnatonni wants to merge 1 commit intoCCExtractor:masterfrom
aparnatonni:fix/strdup-null-check-matroska
Closed

[FIX] Add NULL check for strdup() return value in matroska.c#2204
aparnatonni wants to merge 1 commit intoCCExtractor:masterfrom
aparnatonni:fix/strdup-null-check-matroska

Conversation

@aparnatonni
Copy link
Copy Markdown

In the parse_segment_track_entry() function of the src/lib_ccx/matroska.c file, the strdup("eng") function is called twice without checking the return value, i.e., NULL. If the strdup() function fails, it will return NULL, and the lang variable will become NULL, causing a crash.

Reason for the PR:

Sanity check:

  • I have read and understood the contributors guide
  • I checked that another PR for this does not exist
  • I am NOT adding new C code unless it's to fix an existing bug

The previous fix attempt was given by PR #2163, but it was closed because the fatal() call was missing, and the indentation was incorrect. This PR has follows the pattern used in the ocr.c file at line 57.

Fix:

  • Line 882: NULL check has been added after the first strdup("eng")
  • Line 1049: NULL check has been added after the second strdup("eng")

@aparnatonni aparnatonni force-pushed the fix/strdup-null-check-matroska branch from b3f4ed2 to 378eedc Compare March 16, 2026 02:52
@ccextractor-bot
Copy link
Copy Markdown
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 5c87a33...:
Report Name Tests Passed
Broken 10/13
CEA-708 2/14
DVB 4/7
DVD 3/3
DVR-MS 2/2
General 27/27
Hardsubx 1/1
Hauppage 3/3
MP4 3/3
NoCC 10/10
Options 79/86
Teletext 20/21
WTV 13/13
XDS 34/34

Your PR breaks these cases:

  • ccextractor --startcreditsnotafter 2 --startcreditstext "CCextractor Start crdit Testing" c4dd893cb9...
  • ccextractor --startcreditsforatmost 2 --startcreditstext "CCextractor Start crdit Testing" c4dd893cb9...

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=srt --latin1 --quant 0 85271be4d2..., Last passed: Never
  • ccextractor --autoprogram --out=ttxt --latin1 --ucla dab1c1bd65..., Last passed: Never
  • ccextractor --out=srt --latin1 --autoprogram 29e5ffd34b..., Last passed: Never
  • ccextractor --out=spupng c83f765c66..., 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 --startcreditsforatleast 1 --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.

@ccextractor-bot
Copy link
Copy Markdown
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 5c87a33...:
Report Name Tests Passed
Broken 10/13
CEA-708 2/14
DVB 4/7
DVD 3/3
DVR-MS 2/2
General 27/27
Hardsubx 1/1
Hauppage 3/3
MP4 3/3
NoCC 10/10
Options 81/86
Teletext 20/21
WTV 13/13
XDS 34/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 --autoprogram --out=srt --latin1 --quant 0 85271be4d2..., Last passed: Never
  • ccextractor --autoprogram --out=ttxt --latin1 --ucla dab1c1bd65..., Last passed: Never
  • ccextractor --out=srt --latin1 --autoprogram 29e5ffd34b..., Last passed: Never
  • ccextractor --out=spupng c83f765c66..., 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

This PR does not introduce any new test failures. However, some tests are failing on both master and this PR (see above).

Check the result page for more info.

@cfsmp3
Copy link
Copy Markdown
Contributor

cfsmp3 commented Mar 16, 2026

Closing — the strdup NULL checks in matroska.c are now covered by #2193, which was just merged. Thanks for the PR!

@cfsmp3 cfsmp3 closed this Mar 16, 2026
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.

3 participants