Skip to content

Commit 64f6462

Browse files
danbevMylesBorins
authored andcommitted
src: use smart pointer in AsyncWrap::WeakCallback
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>
1 parent 563bed0 commit 64f6462

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/async_wrap.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -419,14 +419,14 @@ void AsyncWrap::WeakCallback(const v8::WeakCallbackInfo<DestroyParam>& info) {
419419
HandleScope scope(info.GetIsolate());
420420

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

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

432432

0 commit comments

Comments
 (0)