diff options
Diffstat (limited to 'src/shared/cgroup-util.c')
-rw-r--r-- | src/shared/cgroup-util.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/src/shared/cgroup-util.c b/src/shared/cgroup-util.c index 855c9cd160..4ce885601f 100644 --- a/src/shared/cgroup-util.c +++ b/src/shared/cgroup-util.c @@ -1332,11 +1332,10 @@ int cg_pid_get_machine_name(pid_t pid, char **machine) { int cg_path_get_session(const char *path, char **session) { const char *e, *n, *x; - char *s, *r; + char *s; size_t l; assert(path); - assert(session); /* Skip slices, if there are any */ e = skip_slices(path); @@ -1358,11 +1357,16 @@ int cg_path_get_session(const char *path, char **session) { if (l <= 6) return -ENOENT; - r = strndup(x, l - 6); - if (!r) - return -ENOMEM; + if (session) { + char *r; + + r = strndup(x, l - 6); + if (!r) + return -ENOMEM; + + *session = r; + } - *session = r; return 0; } @@ -1370,8 +1374,6 @@ int cg_pid_get_session(pid_t pid, char **session) { _cleanup_free_ char *cgroup = NULL; int r; - assert(session); - r = cg_pid_get_path_shifted(pid, NULL, &cgroup); if (r < 0) return r; |