diff options
author | Lennart Poettering <lennart@poettering.net> | 2013-04-16 03:52:59 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2013-04-16 04:41:21 +0200 |
commit | 54b758dd1422f6a907b04ce309c764c5c91b2e59 (patch) | |
tree | d2235c120335e194feeca792d38c97e8a77f4de8 | |
parent | b45e9abd1dfae17399d404ed5da959bbe8472235 (diff) |
logind: when looking for cgroup prefixes, allocate from stack
-rw-r--r-- | src/login/logind.c | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/src/login/logind.c b/src/login/logind.c index 63422f4c32..aa3e5f0914 100644 --- a/src/login/logind.c +++ b/src/login/logind.c @@ -1041,16 +1041,13 @@ int manager_get_session_by_cgroup(Manager *m, const char *cgroup, Session **sess return 1; } - p = strdup(cgroup); - if (!p) - return log_oom(); + p = strdupa(cgroup); for (;;) { char *e; e = strrchr(p, '/'); if (!e || e == p) { - free(p); *session = NULL; return 0; } @@ -1059,7 +1056,6 @@ int manager_get_session_by_cgroup(Manager *m, const char *cgroup, Session **sess s = hashmap_get(m->session_cgroups, p); if (s) { - free(p); *session = s; return 1; } @@ -1080,7 +1076,7 @@ int manager_get_user_by_cgroup(Manager *m, const char *cgroup, User **user) { return 1; } - p = strdup(cgroup); + p = strdupa(cgroup); if (!p) return log_oom(); @@ -1089,7 +1085,6 @@ int manager_get_user_by_cgroup(Manager *m, const char *cgroup, User **user) { e = strrchr(p, '/'); if (!e || e == p) { - free(p); *user = NULL; return 0; } @@ -1098,7 +1093,6 @@ int manager_get_user_by_cgroup(Manager *m, const char *cgroup, User **user) { u = hashmap_get(m->user_cgroups, p); if (u) { - free(p); *user = u; return 1; } |