summaryrefslogtreecommitdiff
path: root/src/base_object-inl.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/base_object-inl.h')
-rw-r--r--src/base_object-inl.h3
1 files changed, 1 insertions, 2 deletions
diff --git a/src/base_object-inl.h b/src/base_object-inl.h
index d067a807cb..8c8fa1699c 100644
--- a/src/base_object-inl.h
+++ b/src/base_object-inl.h
@@ -95,13 +95,12 @@ void BaseObject::MakeWeak() {
persistent_handle_.SetWeak(
this,
[](const v8::WeakCallbackInfo<BaseObject>& data) {
- BaseObject* obj = data.GetParameter();
+ std::unique_ptr<BaseObject> obj(data.GetParameter());
// Clear the persistent handle so that ~BaseObject() doesn't attempt
// to mess with internal fields, since the JS object may have
// transitioned into an invalid state.
// Refs: https://github.com/nodejs/node/issues/18897
obj->persistent_handle_.Reset();
- delete obj;
}, v8::WeakCallbackType::kParameter);
}