]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
do not try to allocate 0 bytes
authorDavid Tardon <dtardon@redhat.com>
Fri, 12 Oct 2018 12:48:41 +0000 (14:48 +0200)
committerDavid Tardon <dtardon@redhat.com>
Fri, 12 Oct 2018 12:51:35 +0000 (14:51 +0200)
src/shared/fdset.c

index 8c852f11372b13b95ced330c35b8bfd105867804..5d277328c72fbcd93a28b900fc34fb22f65aeba9 100644 (file)
@@ -211,13 +211,16 @@ fail:
 int fdset_close_others(FDSet *fds) {
         void *e;
         Iterator i;
-        int *a;
+        int *a = NULL;
         size_t j = 0, m;
 
         m = fdset_size(fds);
-        a = newa(int, m);
-        SET_FOREACH(e, MAKE_SET(fds), i)
-                a[j++] = PTR_TO_FD(e);
+
+        if (m > 0) {
+                a = newa(int, m);
+                SET_FOREACH(e, MAKE_SET(fds), i)
+                        a[j++] = PTR_TO_FD(e);
+        }
 
         assert(j == m);