diff --git a/tools/bin2c.c b/tools/bin2c.c index fb0a0d9b..0da11988 100644 --- a/tools/bin2c.c +++ b/tools/bin2c.c @@ -40,11 +40,13 @@ int main(int argc, char *argv[]) buffer = malloc(fd_size); if(buffer == NULL) { printf("Failed to allocate memory.\n"); + fclose(source); return 1; } if(fread(buffer,1,fd_size,source) != fd_size) { printf("Failed to read file.\n"); + fclose(source); return 1; } fclose(source); diff --git a/tools/unpack-pbp.c b/tools/unpack-pbp.c index 2ddd9b57..9ca303f8 100644 --- a/tools/unpack-pbp.c +++ b/tools/unpack-pbp.c @@ -92,6 +92,7 @@ int main(int argc, char *argv[]) { fseek(infile, 0, SEEK_SET); if (total_size < 0) { printf("ERROR: Could not get the input file size.\n"); + fclose(infile); return -1; } @@ -99,6 +100,7 @@ int main(int argc, char *argv[]) { size_t result = fread(&header, sizeof(HEADER), 1, infile); if (result < 0) { printf("ERROR: Could not read the input file header.\n"); + fclose(infile); return -1; }