Skip to content

Commit c20b408

Browse files
[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
1 parent 74e3842 commit c20b408

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

src/lib_ccx/general_loop.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,10 +368,19 @@ void process_hex(struct lib_ccx_ctx *ctx, char *filename)
368368
}
369369
/* const char *mpeg_header="00 00 01 b2 43 43 01 f8 "; // Always present */
370370
FILE *fr = fopen(filename, "rt");
371+
if (!fr)
372+
{
373+
fatal(EXIT_READ_ERROR, "In process_hex: Unable to open file %s for reading.", filename);
374+
}
371375
unsigned char *bytes = NULL;
372376
unsigned byte_count = 0;
373377
int warning_shown = 0;
374378
struct demuxer_data *data = alloc_demuxer_data();
379+
if (!data)
380+
{
381+
fclose(fr);
382+
fatal(EXIT_NOT_ENOUGH_MEMORY, "In process_hex: Out of memory allocating demuxer data.");
383+
}
375384
while (fgets(line, max - 1, fr) != NULL)
376385
{
377386
char *c1, *c2 = NULL; // Positions for first and second colons

0 commit comments

Comments
 (0)