mirror of
https://github.com/CCExtractor/ccextractor.git
synced 2026-07-08 18:06:30 +00:00
Fix null pointer dereference in Matroska parser on file open failure (#2171)
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 that calls fatal(EXIT_READ_ERROR, ...) on failure, consistent with other file-open error handling in the codebase.
This commit is contained in:
@@ -2053,6 +2053,12 @@ int matroska_loop(struct lib_ccx_ctx *ctx)
|
||||
mkv_ctx->current_second = 0;
|
||||
mkv_ctx->filename = ctx->inputfile[ctx->current_file];
|
||||
mkv_ctx->file = create_file(ctx);
|
||||
if (mkv_ctx->file == NULL)
|
||||
{
|
||||
char *fname = mkv_ctx->filename;
|
||||
free(mkv_ctx);
|
||||
fatal(EXIT_READ_ERROR, "Could not open MKV file: %s\n", fname);
|
||||
}
|
||||
mkv_ctx->sub_tracks = malloc(sizeof(struct matroska_sub_track **));
|
||||
if (mkv_ctx->sub_tracks == NULL)
|
||||
fatal(EXIT_NOT_ENOUGH_MEMORY, "In matroska_loop: Out of memory allocating sub_tracks.");
|
||||
|
||||
Reference in New Issue
Block a user