mirror of
https://github.com/nodejs/node.git
synced 2026-11-27 17:52:27 -05:00
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: https://github.com/nodejs/node/pull/7711 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Trevor Norris <trev.norris@gmail.com>
This commit is contained in:
1 parent
c354b241a7
commit
4e989b00a3
1 file changed
+1
-1
+1
-1
@@ -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());
|
||||
|
||||
Reference in new issue
Block a user