Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/cares_wrap.cc')
-rw-r--r--src/cares_wrap.cc10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/cares_wrap.cc b/src/cares_wrap.cc
index ee521ce64a0..1fb0f47dd80 100644
--- a/src/cares_wrap.cc
+++ b/src/cares_wrap.cc
@@ -627,8 +627,6 @@ class QueryWrap : public AsyncWrap {
} else {
Parse(response_data_->host.get());
}
-
- delete this;
}
void* MakeCallbackPointer() {
@@ -686,9 +684,13 @@ class QueryWrap : public AsyncWrap {
}
void QueueResponseCallback(int status) {
- env()->SetImmediate([this](Environment*) {
+ BaseObjectPtr<QueryWrap> strong_ref{this};
+ env()->SetImmediate([this, strong_ref](Environment*) {
AfterResponse();
- }, object());
+
+ // Delete once strong_ref goes out of scope.
+ Detach();
+ });
channel_->set_query_last_ok(status != ARES_ECONNREFUSED);
channel_->ModifyActivityQueryCount(-1);