summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2013-04-01 23:11:54 -0400
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2013-04-01 23:43:49 -0400
commit050fbdb8787fb9e3f4491189cbb0fd1d130fe234 (patch)
tree465a82c715d8eec1411678a518e4af9a65d7fc8e /src
parent131601349515f05b50fec4821ede38f5037ec9f4 (diff)
shared/cgroup-show: fix leak of "pid"
Diffstat (limited to 'src')
-rw-r--r--src/shared/cgroup-show.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/src/shared/cgroup-show.c b/src/shared/cgroup-show.c
index 2f2669f828..966af5e24c 100644
--- a/src/shared/cgroup-show.c
+++ b/src/shared/cgroup-show.c
@@ -282,7 +282,7 @@ int show_cgroup(const char *controller, const char *path, const char *prefix, un
}
static int show_extra_pids(const char *controller, const char *path, const char *prefix, unsigned n_columns, const pid_t pids[], unsigned n_pids, OutputFlags flags) {
- pid_t *copy;
+ pid_t _cleanup_free_ *copy = NULL;
unsigned i, j;
int r;
@@ -303,13 +303,11 @@ static int show_extra_pids(const char *controller, const char *path, const char
return -ENOMEM;
for (i = 0, j = 0; i < n_pids; i++) {
- char *k;
+ char _cleanup_free_ *k = NULL;
r = cg_get_by_pid(controller, pids[i], &k);
- if (r < 0) {
- free(copy);
+ if (r < 0)
return r;
- }
if (path_startswith(k, path))
continue;
@@ -319,7 +317,6 @@ static int show_extra_pids(const char *controller, const char *path, const char
show_pid_array(copy, j, prefix, n_columns, true, false, false, flags);
- free(copy);
return 0;
}