Skip to content

Commit

Permalink
src: use smart pointer in AsyncWrap::WeakCallback
Browse files Browse the repository at this point in the history
PR-URL: #19168
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Joyee Cheung <[email protected]>
  • Loading branch information
danbev authored and targos committed Mar 17, 2018
1 parent e85f703 commit 5dde091
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/async_wrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -419,14 +419,14 @@ void AsyncWrap::WeakCallback(const v8::WeakCallbackInfo<DestroyParam>& info) {
HandleScope scope(info.GetIsolate());

Environment* env = Environment::GetCurrent(info.GetIsolate());
DestroyParam* p = info.GetParameter();
std::unique_ptr<DestroyParam> p{info.GetParameter()};
Local<Object> prop_bag = PersistentToLocal(info.GetIsolate(), p->propBag);

Local<Value> val = prop_bag->Get(env->destroyed_string());
if (val->IsFalse()) {
AsyncWrap::EmitDestroy(env, p->asyncId);
}
delete p;
// unique_ptr goes out of scope here and pointer is deleted.
}


Expand Down

0 comments on commit 5dde091

Please sign in to comment.