diff options
author | Daniel Bevenius <daniel.bevenius@gmail.com> | 2018-09-27 09:36:01 +0300 |
---|---|---|
committer | Daniel Bevenius <daniel.bevenius@gmail.com> | 2018-10-01 09:10:07 +0300 |
commit | 7ac109df10eb8d31bb7503b031ff85a14bb5ec84 (patch) | |
tree | ce25a9b98b668efeaf77251fdc5bf212c7e8571c /src/base_object-inl.h | |
parent | 1be804d625e6904f053b09b9066ba32e0f48fa99 (diff) |
src: use unique_ptr for obj in SetWeak lambda
PR-URL: https://github.com/nodejs/node/pull/23117
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'src/base_object-inl.h')
-rw-r--r-- | src/base_object-inl.h | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/src/base_object-inl.h b/src/base_object-inl.h index d067a807cb8..8c8fa1699c3 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); } |