* [LTP] [PATCH]: Fix memory leaks and remove redundant code
@ 2015-05-28 4:41 Manjeet Pawar
2015-06-01 14:48 ` Cyril Hrubis
0 siblings, 1 reply; 2+ messages in thread
From: Manjeet Pawar @ 2015-05-28 4:41 UTC (permalink / raw)
To: ltp-list@lists.sourceforge.net; +Cc: ajeet.y@samsung.com, Yogesh Narayan Gaur
From: Manjeet Pawar <manjeet.p@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 <manjeet.p@samsung.com>
Signed-off-by: Yogesh Gaur <yn.gaur@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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [LTP] [PATCH]: Fix memory leaks and remove redundant code
2015-05-28 4:41 [LTP] [PATCH]: Fix memory leaks and remove redundant code Manjeet Pawar
@ 2015-06-01 14:48 ` Cyril Hrubis
0 siblings, 0 replies; 2+ messages in thread
From: Cyril Hrubis @ 2015-06-01 14:48 UTC (permalink / raw)
To: Manjeet Pawar
Cc: ajeet.y@samsung.com, ltp-list@lists.sourceforge.net,
Yogesh Narayan Gaur
Hi!
Pushed, thanks.
--
Cyril Hrubis
chrubis@suse.cz
------------------------------------------------------------------------------
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-06-01 14:49 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-28 4:41 [LTP] [PATCH]: Fix memory leaks and remove redundant code Manjeet Pawar
2015-06-01 14:48 ` Cyril Hrubis
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox