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 MylesBorins committed Oct 26, 2016
1 parent dadcf6b commit 6838ad5
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 @@ -394,9 +394,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(1, &ptr));
}
Expand Down

0 comments on commit 6838ad5

Please sign in to comment.