[FIX] Add NULL checks for fopen() and alloc_demuxer_data() in process_hex() (#2202)

* fix(general_loop): Add NULL checks for fopen() and alloc_demuxer_data() in process_hex()

* docs: update changelog for process_hex NULL checks fix

* fix: use EXIT_READ_ERROR for fopen failure and remove CHANGES.TXT entry
This commit is contained in:
Navdeep Kaur
2026-03-28 23:55:40 +05:30
committed by GitHub
parent 74e3842ed0
commit c20b408527

View File

@@ -368,10 +368,19 @@ void process_hex(struct lib_ccx_ctx *ctx, char *filename)
}
/* const char *mpeg_header="00 00 01 b2 43 43 01 f8 "; // Always present */
FILE *fr = fopen(filename, "rt");
if (!fr)
{
fatal(EXIT_READ_ERROR, "In process_hex: Unable to open file %s for reading.", filename);
}
unsigned char *bytes = NULL;
unsigned byte_count = 0;
int warning_shown = 0;
struct demuxer_data *data = alloc_demuxer_data();
if (!data)
{
fclose(fr);
fatal(EXIT_NOT_ENOUGH_MEMORY, "In process_hex: Out of memory allocating demuxer data.");
}
while (fgets(line, max - 1, fr) != NULL)
{
char *c1, *c2 = NULL; // Positions for first and second colons