Skip to content

Commit

Permalink
src: fix handle leak in UDPWrap::Instantiate()
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
bnoordhuis authored and evanlucas committed Jul 20, 2016
1 parent dc766e6 commit 78dcf0d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/udp_wrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -436,9 +436,9 @@ void UDPWrap::OnRecv(uv_udp_t* handle,


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

0 comments on commit 78dcf0d

Please sign in to comment.