diff --git a/src/lib/ares_event_win32.c b/src/lib/ares_event_win32.c index ac41038b..538e5373 100644 --- a/src/lib/ares_event_win32.c +++ b/src/lib/ares_event_win32.c @@ -791,7 +791,11 @@ static void ares_evsys_win32_event_mod(ares_event_t *event, static ares_bool_t ares_evsys_win32_process_other_event( ares_evsys_win32_t *ew, ares_evsys_win32_eventdata_t *ed, size_t i) { - ares_event_t *event = ed->event; + ares_event_t *event; + + /* NOTE: do NOT dereference 'ed' if during shutdown as this could be an + * invalid pointer if the signal handle was cleaned up, but there was still a + * pending event! */ if (ew->is_shutdown) { CARES_DEBUG_LOG("\t\t** i=%lu, skip non-socket handle during shutdown\n", @@ -799,6 +803,7 @@ static ares_bool_t ares_evsys_win32_process_other_event( return ARES_FALSE; } + event = ed->event; CARES_DEBUG_LOG("\t\t** i=%lu, ed=%p (data)\n", (unsigned long)i, (void *)ed); event->cb(event->e, event->fd, event->data, ARES_EVENT_FLAG_OTHER);