From 7ac109df10eb8d31bb7503b031ff85a14bb5ec84 Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Thu, 27 Sep 2018 08:36:01 +0200 Subject: src: use unique_ptr for obj in SetWeak lambda PR-URL: https://github.com/nodejs/node/pull/23117 Reviewed-By: Anna Henningsen Reviewed-By: James M Snell --- src/base_object-inl.h | 3 +-- 1 file changed, 1 insertion(+), 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& data) { - BaseObject* obj = data.GetParameter(); + std::unique_ptr 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); } -- cgit v1.2.3