From 20a4f14c576d4176c516deb4d7c5f41210b443a4 Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Thu, 27 Sep 2018 08:20:53 +0200 Subject: [PATCH] src: make req_wrap a unique_ptr in AfterConnect MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/23115 Reviewed-By: Gireesh Punathil Reviewed-By: Michaƫl Zasso Reviewed-By: Anna Henningsen Reviewed-By: Colin Ihrig Reviewed-By: Sakthipriyan Vairamani Reviewed-By: Joyee Cheung Reviewed-By: James M Snell --- src/connection_wrap.cc | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/connection_wrap.cc b/src/connection_wrap.cc index 3021307c065511..db239f9becdb53 100644 --- a/src/connection_wrap.cc +++ b/src/connection_wrap.cc @@ -77,7 +77,8 @@ void ConnectionWrap::OnConnection(uv_stream_t* handle, template void ConnectionWrap::AfterConnect(uv_connect_t* req, int status) { - ConnectWrap* req_wrap = static_cast(req->data); + std::unique_ptr req_wrap + (static_cast(req->data)); CHECK_NOT_NULL(req_wrap); WrapType* wrap = static_cast(req->handle->data); CHECK_EQ(req_wrap->env(), wrap->env()); @@ -108,8 +109,6 @@ void ConnectionWrap::AfterConnect(uv_connect_t* req, }; req_wrap->MakeCallback(env->oncomplete_string(), arraysize(argv), argv); - - delete req_wrap; } template ConnectionWrap::ConnectionWrap(