From: Andrea Dalla Costa Date: Sat, 28 Dec 2019 16:43:40 +0000 (+0100) Subject: uboot-oxnas: fix memory leak in tool mkox820crc X-Git-Tag: v21.02.0-rc1~4023 X-Git-Url: http://git.cdn.openwrt.org/?a=commitdiff_plain;h=5adca1cf2abc0c320be082522ab1ec747c7157b7;p=openwrt%2Fstaging%2Fhauke.git uboot-oxnas: fix memory leak in tool mkox820crc 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 --- diff --git a/package/boot/uboot-oxnas/src/tools/mkox820crc.c b/package/boot/uboot-oxnas/src/tools/mkox820crc.c index d100191f2d..873706245b 100644 --- a/package/boot/uboot-oxnas/src/tools/mkox820crc.c +++ b/package/boot/uboot-oxnas/src/tools/mkox820crc.c @@ -84,6 +84,7 @@ int main(int argc, char **argv) if (status != file_length) { printf("Failed to load image\n"); + free(executable); return -ENOENT; } @@ -111,6 +112,7 @@ int main(int argc, char **argv) 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)); @@ -118,6 +120,7 @@ int main(int argc, char **argv) len = write(in_file, executable, file_length); assert(len == file_length); close(in_file); + free(executable); return 0; }