Fix null pointer dereference in Matroska parser on file open failure#2171
Open
apoorvdarshan wants to merge 1 commit intoCCExtractor:masterfrom
Open
Fix null pointer dereference in Matroska parser on file open failure#2171apoorvdarshan wants to merge 1 commit intoCCExtractor:masterfrom
apoorvdarshan wants to merge 1 commit intoCCExtractor:masterfrom
Conversation
create_file() returns the result of fopen() which can be NULL if the file cannot be opened. matroska_loop() never checked this, passing the NULL pointer into matroska_parse() where it is immediately used in feof(), causing a crash. Add a NULL check and return an error.
cfsmp3
requested changes
Mar 7, 2026
Contributor
cfsmp3
left a comment
There was a problem hiding this comment.
Same issue as the feedback on #2157: use fatal(EXIT_READ_ERROR, ...) instead of mprint() + return. If the input file can't be opened, the program should exit with a proper error code, not silently return and appear to succeed. The very next error check in this function (malloc for sub_tracks) uses fatal() — be consistent.
Also remove the CHANGES.TXT entry — this is an internal fix, not a user-reported bug.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
create_file()returns the result offopen()without checking for NULLmatroska_loop()passes this directly intomatroska_parse(), which callsfeof()on the NULL pointer, crashing the programcreate_file()that prints an error, freesmkv_ctx, and returns-1Test plan