From: Manjeet Pawar <manjee...@samsung.com> Subject: [PATCH] lib/self_exec.c: free args before returning from function to avoid memory leaks and remove redundant code in self_exec()
This patch free args before returning from function to avoid memory leaks and remove redundant code in self_exec() Signed-off-by: Manjeet Pawar <manjee...@samsung.com> Signed-off-by: Yogesh Gaur <yn.g...@samsung.com> --- lib/self_exec.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/self_exec.c b/lib/self_exec.c index 06af313..e8f1ee6 100644 --- a/lib/self_exec.c +++ b/lib/self_exec.c @@ -117,6 +117,7 @@ void maybe_run_child(void (*child) (), char *fmt, ...) } if (j != i) { va_end(ap); + free(args); return; } break; @@ -144,7 +145,7 @@ void maybe_run_child(void (*child) (), char *fmt, ...) } va_end(ap); - + free(args); if (chdir(child_dir) < 0) tst_brkm(TBROK, NULL, "Could not change to %s for child", child_dir); @@ -170,8 +171,7 @@ int self_exec(char *argv0, char *fmt, ...) } arg = strdup(tmp_cwd); - - if ((arg = strdup(tmp_cwd)) == NULL) { + if (arg == NULL) { tst_resm(TBROK, "Could not produce self_exec string"); return -1; } -- 1.7.9.5 ------------------------------------------------------------------------------ _______________________________________________ Ltp-list mailing list Ltp-list@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/ltp-list