]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
kill: potential null derefence [smatch scan]
authorKarel Zak <kzak@redhat.com>
Mon, 12 Sep 2011 13:40:24 +0000 (15:40 +0200)
committerKarel Zak <kzak@redhat.com>
Tue, 18 Oct 2011 12:22:27 +0000 (14:22 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
misc-utils/procs.c

index 3f52387de7a4869b6bd9ec23f466260847fac6ad..1fafc9bbe482079106b83bea4375f9001076fac1 100644 (file)
@@ -79,11 +79,13 @@ get_pids (char *process_name, int get_all) {
            pids_size += 5;
            pids = (int *) realloc (pids, sizeof (int) * pids_size);
        }
-       pids[num_pids++] = pid;
-       pids[num_pids] = -1;
+       if (pids) {
+               pids[num_pids++] = pid;
+               pids[num_pids] = -1;
+       }
     }
     closedir (dir);
-    return (pids);
+    return pids;
 }
 
 /*