From 1e3dd8bf5589394827a57aaa91854add7e43958d Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Tue, 6 Mar 2018 11:53:15 +0100 Subject: [PATCH] src: use smart pointer in AsyncWrap::WeakCallback PR-URL: https://github.com/nodejs/node/pull/19168 Reviewed-By: Anna Henningsen Reviewed-By: Colin Ihrig Reviewed-By: James M Snell Reviewed-By: Joyee Cheung --- src/async_wrap.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/async_wrap.cc b/src/async_wrap.cc index 08bb73f7468707..e2656e4eec3970 100644 --- a/src/async_wrap.cc +++ b/src/async_wrap.cc @@ -415,14 +415,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. }