Browse Source

[core] don't call fd event handlers more than once, they might already be gone (fixes segfault)

personal/stbuehler/fix-fdevent
Stefan Bühler 3 years ago
parent
commit
1bd1d559b5
  1. 2
      src/fdevent_poll.c
  2. 2
      src/fdevent_select.c

2
src/fdevent_poll.c

@ -164,7 +164,7 @@ static int fdevent_poll_poll(fdevents *ev, int timeout_ms) {
for (int ndx = -1, i = 0; i < n; ++i) {
fdnode *fdn;
ndx = fdevent_poll_event_next_fdndx(ev, ndx);
if (-1 == ndx) continue;
if (-1 == ndx) break;
fdn = ev->fdarray[ndx];
if (0 == ((uintptr_t)fdn & 0x3)) {
int revents = fdevent_poll_event_get_revent(ev, i);

2
src/fdevent_select.c

@ -102,7 +102,7 @@ static int fdevent_select_poll(fdevents *ev, int timeout_ms) {
for (int ndx = -1, i = 0; i < n; ++i) {
fdnode *fdn;
ndx = fdevent_select_event_next_fdndx(ev, ndx);
if (-1 == ndx) continue;
if (-1 == ndx) break;
fdn = ev->fdarray[ndx];
if (0 == ((uintptr_t)fdn & 0x3)) {
int revents = fdevent_select_event_get_revent(ev, ndx);

Loading…
Cancel
Save