diff --git a/src/async_wrap.cc b/src/async_wrap.cc index cd9f26d7782d46..63098e5c7b5b89 100644 --- a/src/async_wrap.cc +++ b/src/async_wrap.cc @@ -419,14 +419,14 @@ void AsyncWrap::WeakCallback(const v8::WeakCallbackInfo& info) { HandleScope scope(info.GetIsolate()); Environment* env = Environment::GetCurrent(info.GetIsolate()); - DestroyParam* p = info.GetParameter(); + std::unique_ptr p{info.GetParameter()}; Local prop_bag = PersistentToLocal(info.GetIsolate(), p->propBag); Local 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. }