Skip to content

Commit 698a6a9

Browse files
committed
unix/moduselect: poll.register(): Reuse freed entries in poll array.
1 parent 19920e2 commit 698a6a9

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

unix/moduselect.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,15 @@ STATIC mp_obj_t poll_register(uint n_args, const mp_obj_t *args) {
5858
if (self->len < self->alloc) {
5959
i = self->len++;
6060
} else {
61-
assert(0);
61+
struct pollfd *entries = self->entries;
62+
for (i = 0; i < self->len; i++, entries++) {
63+
if (entries->fd == -1) {
64+
break;
65+
}
66+
}
67+
if (entries->fd != -1) {
68+
assert(0);
69+
}
6270
}
6371

6472
self->entries[i].fd = mp_obj_get_int(args[1]);

0 commit comments

Comments
 (0)