Skip to content

Commit 2af058e

Browse files
fix(lib_ccx): add NULL checks for fopen and alloc_demuxer_data in process_hex (#2201)
1 parent 6b3bea4 commit 2af058e

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

src/lib_ccx/general_loop.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,10 +368,21 @@ 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+
free(line);
374+
fatal(EXIT_FAILURE, "In process_hex: Cannot open %s.", filename);
375+
}
371376
unsigned char *bytes = NULL;
372377
unsigned byte_count = 0;
373378
int warning_shown = 0;
374379
struct demuxer_data *data = alloc_demuxer_data();
380+
if (!data)
381+
{
382+
fclose(fr);
383+
free(line);
384+
fatal(EXIT_NOT_ENOUGH_MEMORY, "In process_hex: Out of memory allocating demuxer data.");
385+
}
375386
while (fgets(line, max - 1, fr) != NULL)
376387
{
377388
char *c1, *c2 = NULL; // Positions for first and second colons

0 commit comments

Comments
 (0)