Skip to content

Commit 6838ad5

Browse files
bnoordhuisMylesBorins
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 dadcf6b commit 6838ad5

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
@@ -394,9 +394,9 @@ void UDPWrap::OnRecv(uv_udp_t* handle,
394394

395395

396396
Local<Object> UDPWrap::Instantiate(Environment* env, AsyncWrap* parent) {
397+
EscapableHandleScope scope(env->isolate());
397398
// If this assert fires then Initialize hasn't been called yet.
398399
CHECK_EQ(env->udp_constructor_function().IsEmpty(), false);
399-
EscapableHandleScope scope(env->isolate());
400400
Local<Value> ptr = External::New(env->isolate(), parent);
401401
return scope.Escape(env->udp_constructor_function()->NewInstance(1, &ptr));
402402
}

0 commit comments

Comments
 (0)