diff options
author | Lennart Poettering <lennart@poettering.net> | 2011-09-23 02:39:28 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2011-09-23 16:28:27 +0200 |
commit | de3756ab9916551f3f4f1f360aee59aeed238b5b (patch) | |
tree | d3f8fc787262362d6edd63819fbab60cc6b0d285 /src | |
parent | 4e240ab0c93f4d454b065eef7074132969ac6f16 (diff) |
llvm-analyze: fix some bugs found by llvm-analyze
Diffstat (limited to 'src')
-rw-r--r-- | src/loginctl.c | 3 | ||||
-rw-r--r-- | src/sd-login.c | 41 | ||||
-rw-r--r-- | src/socket.c | 6 |
3 files changed, 30 insertions, 20 deletions
diff --git a/src/loginctl.c b/src/loginctl.c index ba8020df23..811c3f1a90 100644 --- a/src/loginctl.c +++ b/src/loginctl.c @@ -1063,10 +1063,9 @@ static int show(DBusConnection *bus, char **args, unsigned n) { uid_t uid; uint32_t u; - r = get_user_creds((const char**) (args+i), &uid, NULL, NULL); + ret = get_user_creds((const char**) (args+i), &uid, NULL, NULL); if (r < 0) { log_error("User %s unknown.", args[i]); - r = -ENOENT; goto finish; } diff --git a/src/sd-login.c b/src/sd-login.c index b670d18266..a0a56c4952 100644 --- a/src/sd-login.c +++ b/src/sd-login.c @@ -481,34 +481,39 @@ _public_ int sd_seat_get_sessions(const char *seat, char ***sessions, uid_t **ui if (uids && t) { char *w, *state; size_t l; - unsigned i = 0; FOREACH_WORD(w, l, t, state) n++; - b = new(uid_t, n); - if (!b) { - strv_free(a); - return -ENOMEM; - } + if (n == 0) + b = NULL; + else { + unsigned i = 0; - FOREACH_WORD(w, l, t, state) { - char *k; - - k = strndup(w, l); - if (!k) { - free(t); - free(b); + b = new(uid_t, n); + if (!b) { strv_free(a); return -ENOMEM; } - r = parse_uid(k, b + i); - free(k); - if (r < 0) - continue; + FOREACH_WORD(w, l, t, state) { + char *k; - i++; + k = strndup(w, l); + if (!k) { + free(t); + free(b); + strv_free(a); + return -ENOMEM; + } + + r = parse_uid(k, b + i); + free(k); + if (r < 0) + continue; + + i++; + } } } diff --git a/src/socket.c b/src/socket.c index a1b451eba0..7ddf326a22 100644 --- a/src/socket.c +++ b/src/socket.c @@ -1962,6 +1962,12 @@ int socket_collect_fds(Socket *s, int **fds, unsigned *n_fds) { if (p->fd >= 0) rn_fds++; + if (rn_fds <= 0) { + *fds = NULL; + *n_fds = 0; + return 0; + } + if (!(rfds = new(int, rn_fds))) return -ENOMEM; |