diff --git a/src/udp_wrap.cc b/src/udp_wrap.cc index be1f59d2c52863..5702ba5ad2fe7d 100644 --- a/src/udp_wrap.cc +++ b/src/udp_wrap.cc @@ -444,7 +444,7 @@ void UDPWrap::RecvStop(const FunctionCallbackInfo& args) { void UDPWrap::OnSend(uv_udp_send_t* req, int status) { - SendWrap* req_wrap = static_cast(req->data); + std::unique_ptr req_wrap{static_cast(req->data)}; if (req_wrap->have_callback()) { Environment* env = req_wrap->env(); HandleScope handle_scope(env->isolate()); @@ -455,7 +455,6 @@ void UDPWrap::OnSend(uv_udp_send_t* req, int status) { }; req_wrap->MakeCallback(env->oncomplete_string(), 2, arg); } - delete req_wrap; }