report: Dynamic memory, referenced by 'return value of xasprintf(...)', is allocated at xfuncs_printf.c:344 by calling function 'xasprintf' at bootchartd.c:318 and lost at bootchartd.c:320.
Corrections explained: - Fixed a memory leak caused by not freeing the result of `xasprintf`. - Added a variable `cmd` to store the result of `xasprintf`. - Freed `cmd` after calling `system(cmd)`. Triggers found by static analyzer Svace. Signed-off-by: Anton Moryakov <[email protected]> --- init/bootchartd.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/init/bootchartd.c b/init/bootchartd.c index 0929890a3..e12fb16d6 100644 --- a/init/bootchartd.c +++ b/init/bootchartd.c @@ -315,7 +315,10 @@ static void finalize(char *tempdir, const char *prog, int process_accounting) fclose(header_fp); /* Package log files */ - system(xasprintf("tar -zcf /var/log/bootlog.tgz header %s *.log", process_accounting ? "kernel_pacct" : "")); + char *cmd = xasprintf("tar -zcf /var/log/bootlog.tgz header %s *.log", process_accounting ? "kernel_pacct" : ""); + system(cmd); + free(cmd); + /* Clean up (if we are not in detached tmpfs) */ if (tempdir) { unlink("header"); -- 2.30.2 _______________________________________________ busybox mailing list [email protected] https://lists.busybox.net/mailman/listinfo/busybox
