Skip to content

Commit acbb629

Browse files
theanarkhruyadorno
authored andcommitted
src: fix dns crash when failed to create NodeAresTask
PR-URL: #55521 Fixes: #52439 Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent d2430ee commit acbb629

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

src/cares_wrap.cc

+4-9
Original file line numberDiff line numberDiff line change
@@ -145,14 +145,10 @@ void ares_sockstate_cb(void* data, ares_socket_t sock, int read, int write) {
145145
ares_poll_cb);
146146

147147
} else {
148-
/* read == 0 and write == 0 this is c-ares's way of notifying us that */
149-
/* the socket is now closed. We must free the data associated with */
150-
/* socket. */
151-
CHECK(task &&
152-
"When an ares socket is closed we should have a handle for it");
153-
154-
channel->task_list()->erase(it);
155-
channel->env()->CloseHandle(&task->poll_watcher, ares_poll_close_cb);
148+
if (task != nullptr) {
149+
channel->task_list()->erase(it);
150+
channel->env()->CloseHandle(&task->poll_watcher, ares_poll_close_cb);
151+
}
156152

157153
if (channel->task_list()->empty()) {
158154
channel->CloseTimer();
@@ -683,7 +679,6 @@ GetNameInfoReqWrap::GetNameInfoReqWrap(
683679
void ChannelWrap::AresTimeout(uv_timer_t* handle) {
684680
ChannelWrap* channel = static_cast<ChannelWrap*>(handle->data);
685681
CHECK_EQ(channel->timer_handle(), handle);
686-
CHECK_EQ(false, channel->task_list()->empty());
687682
ares_process_fd(channel->cares_channel(), ARES_SOCKET_BAD, ARES_SOCKET_BAD);
688683
}
689684

0 commit comments

Comments
 (0)