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 <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
  • Loading branch information
danbev authored and MylesBorins committed Mar 20, 2018
1 parent 563bed0 commit 64f6462
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 64f6462

Please sign in to comment.