Skip to content

Commit 78dcf0d

Browse files
bnoordhuisevanlucas
authored andcommitted
src: fix handle leak in UDPWrap::Instantiate()
Create a handle scope before performing a check that creates a handle, otherwise the handle is leaked into the handle scope of the caller. PR-URL: #7711 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Trevor Norris <[email protected]>
1 parent dc766e6 commit 78dcf0d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/udp_wrap.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -436,9 +436,9 @@ void UDPWrap::OnRecv(uv_udp_t* handle,
436436

437437

438438
Local<Object> UDPWrap::Instantiate(Environment* env, AsyncWrap* parent) {
439+
EscapableHandleScope scope(env->isolate());
439440
// If this assert fires then Initialize hasn't been called yet.
440441
CHECK_EQ(env->udp_constructor_function().IsEmpty(), false);
441-
EscapableHandleScope scope(env->isolate());
442442
Local<Value> ptr = External::New(env->isolate(), parent);
443443
return scope.Escape(env->udp_constructor_function()
444444
->NewInstance(env->context(), 1, &ptr).ToLocalChecked());

0 commit comments

Comments
 (0)