Permalink
Browse files

utils/genhdr: Fix memory leaks

Signed-off-by: Francois Berder <fberder@outlook.fr>
  • Loading branch information...
francois-berder committed Jan 18, 2019
1 parent 3fe4b14 commit 3debd52b40bd66a06a93f116e888fdc3a87bbb3c
Showing with 4 additions and 0 deletions.
  1. +4 −0 src/utils/genhdr.c
@@ -70,6 +70,7 @@ int main(int argc, char **argv) {

if(flen+256 < flen) {
printf("File too large ;)\n");
fclose(f);
return 1;
}
char *remaining = NULL;
@@ -86,6 +87,8 @@ int main(int argc, char **argv) {
uint8_t *buf = malloc(flen+256);
if(!buf) {
perror("malloc");
fclose(f);
return -1;
}
memset(buf, 0xff, 256);
fseek(f, 0, SEEK_SET);
@@ -122,5 +125,6 @@ int main(int argc, char **argv) {
fseek(f, 0, SEEK_SET);
fwrite(buf, 1, 256+flen, f);
fclose(f);
free(buf);
return 0;
}

0 comments on commit 3debd52

Please sign in to comment.