From 78dcf0d641e1649703349ada338b3a3dec48c7e6 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Wed, 13 Jul 2016 16:16:52 +0200 Subject: [PATCH] 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 Reviewed-By: Colin Ihrig Reviewed-By: Trevor Norris --- src/udp_wrap.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/udp_wrap.cc b/src/udp_wrap.cc index bd7aa418bd89cf..a0d8b1f7613b61 100644 --- a/src/udp_wrap.cc +++ b/src/udp_wrap.cc @@ -436,9 +436,9 @@ void UDPWrap::OnRecv(uv_udp_t* handle, Local 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 ptr = External::New(env->isolate(), parent); return scope.Escape(env->udp_constructor_function() ->NewInstance(env->context(), 1, &ptr).ToLocalChecked());