]> err.no Git - systemd/commitdiff
llvm-analyze: fix some bugs found by llvm-analyze
authorLennart Poettering <lennart@poettering.net>
Fri, 23 Sep 2011 00:39:28 +0000 (02:39 +0200)
committerLennart Poettering <lennart@poettering.net>
Fri, 23 Sep 2011 14:28:27 +0000 (16:28 +0200)
src/loginctl.c
src/sd-login.c
src/socket.c

index ba8020df23972563bc0b6973bd50ec7798062c32..811c3f1a90ae89a5f508ebfcc98f476523a0f293 100644 (file)
@@ -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;
                         }
 
index b670d18266a7a85ec557e8efa698be158755c411..a0a56c49526ebdf2fb85a83137418b2e8c77d679 100644 (file)
@@ -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++;
+                        }
                 }
         }
 
index a1b451eba0f9bd640f35fdeb6c3b7a4a148c667b..7ddf326a2252c40481b5b86124dd45f25945d13a 100644 (file)
@@ -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;