diff --git a/io/io_waituntil2.c b/io/io_waituntil2.c index 5bef5af..1850d55 100644 --- a/io/io_waituntil2.c +++ b/io/io_waituntil2.c @@ -123,12 +123,11 @@ int64 io_waituntil2(int64 milliseconds) { if (first_deferred!=-1) { while (first_deferred!=-1) { io_entry* e=iarray_get(&io_fds,first_deferred); - if (e) { - if (e->closed) { - e->closed=0; - close(first_deferred); - } + if (e && e->closed) { + e->closed=0; + close(first_deferred); first_deferred=e->next_defer; + e->next_defer=-1; } else first_deferred=-1; // can't happen }