Skip to content

Commit 7f444ff

Browse files
committed
[squash] close memory leak
1 parent 244462b commit 7f444ff

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/async-wrap.cc

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -295,12 +295,11 @@ static void PromiseHook(PromiseHookType type, Local<Promise> promise,
295295
Environment* env = Environment::GetCurrent(context);
296296
if (type == PromiseHookType::kInit) {
297297
PromiseWrap* wrap = new PromiseWrap(env, promise);
298-
promise->SetAlignedPointerInInternalField(0, wrap);
298+
wrap->MakeWeak(wrap);
299299
} else if (type == PromiseHookType::kResolve) {
300300
// TODO(matthewloring): need to expose this through the async hooks api.
301301
}
302-
PromiseWrap* wrap =
303-
static_cast<PromiseWrap*>(promise->GetAlignedPointerFromInternalField(0));
302+
PromiseWrap* wrap = Unwrap<PromiseWrap>(promise);
304303
CHECK_NE(wrap, nullptr);
305304
if (type == PromiseHookType::kBefore) {
306305
PreCallbackExecution(wrap, false);

0 commit comments

Comments
 (0)