do not try to allocate 0 bytes

This commit is contained in:
David Tardon 2018-10-12 14:48:41 +02:00
parent f369f47c26
commit 8192548ef7
1 changed files with 7 additions and 4 deletions

View 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);