Add missing calls to `free` for variable `mem`.
Add missing call to `fclose` for variable `f`.
The same changes were made in both `mkfwimage.c` and `mkfwimage2.c`.
Signed-off-by: Andrea Dalla Costa <andrea@dallacosta.me>
if ((f = fopen(im->outputfile, "w")) == NULL)
{
ERROR("Can not create output file: '%s'\n", im->outputfile);
+ free(mem);
return -10;
}
{
ERROR("Could not write %d bytes into file: '%s'\n",
mem_size, im->outputfile);
+ free(mem);
+ fclose(f);
return -11;
}
/* write in-memory buffer into file */
if ((f = fopen(im.outputfile, "w")) == NULL) {
ERROR("Can not create output file: '%s'\n", im.outputfile);
+ free(mem);
return -10;
}
if (fwrite(mem, mem_size, 1, f) != 1) {
ERROR("Could not write %d bytes into file: '%s'\n",
mem_size, im.outputfile);
+ free(mem);
+ fclose(f);
return -11;
}