In function `main` add calls to `free` for the variable `executable`.
This is needed because the variable `executable` is allocated but
never freed. This cause a memory leak.
Signed-off-by: Andrea Dalla Costa <andrea@dallacosta.me>
if (status != file_length) {
printf("Failed to load image\n");
+ free(executable);
return -ENOENT;
}
status = lseek(in_file, 0, SEEK_SET);
if (status != 0) {
printf("failed to rewind\n");
+ free(executable);
return 1;
}
len = write(in_file, &img_header, sizeof(img_header));
len = write(in_file, executable, file_length);
assert(len == file_length);
close(in_file);
+ free(executable);
return 0;
}