Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
src: use unique_ptr for obj in SetWeak lambda
  • Loading branch information
danbev committed Sep 27, 2018
commit cc262a79199167ff4300fa3c02a51e8ae92a6004
3 changes: 1 addition & 2 deletions src/base_object-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Comment thread
addaleax marked this conversation as resolved.
delete obj;
}, v8::WeakCallbackType::kParameter);
}

Expand Down