mirror of
https://github.com/systemd/systemd.git
synced 2025-02-04 21:47:31 +03:00
shared/cgroup-show: fix leak of "pid"
This commit is contained in:
parent
1316013495
commit
050fbdb878
@ -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) {
|
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;
|
unsigned i, j;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
@ -303,13 +303,11 @@ static int show_extra_pids(const char *controller, const char *path, const char
|
|||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
for (i = 0, j = 0; i < n_pids; i++) {
|
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);
|
r = cg_get_by_pid(controller, pids[i], &k);
|
||||||
if (r < 0) {
|
if (r < 0)
|
||||||
free(copy);
|
|
||||||
return r;
|
return r;
|
||||||
}
|
|
||||||
|
|
||||||
if (path_startswith(k, path))
|
if (path_startswith(k, path))
|
||||||
continue;
|
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);
|
show_pid_array(copy, j, prefix, n_columns, true, false, false, flags);
|
||||||
|
|
||||||
free(copy);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user