From 97c0a3493529666e241277b199fca2d4e093121a Mon Sep 17 00:00:00 2001 From: cjihrig Date: Wed, 3 Apr 2019 10:48:35 -0400 Subject: [PATCH] src: don't point to out of scope variable Coverity reported this. The addr pointer is passed to req_wrap->Dispatch(). By the time this happens, the value that addr points to, addr_storage, is out of scope. This commit remedies that. PR-URL: https://github.com/nodejs/node/pull/27070 Reviewed-By: Anna Henningsen Reviewed-By: Santiago Gimeno Reviewed-By: Richard Lau Reviewed-By: Gus Caplan Reviewed-By: Luigi Pinca Reviewed-By: Yongsheng Zhang Reviewed-By: Minwoo Jung --- 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 c4be8a6068b097..59df0232fabc4d 100644 --- a/src/udp_wrap.cc +++ b/src/udp_wrap.cc @@ -451,9 +451,9 @@ void UDPWrap::DoSend(const FunctionCallbackInfo& args, int family) { req_wrap->msg_size = msg_size; int err = 0; + struct sockaddr_storage addr_storage; sockaddr* addr = nullptr; if (sendto) { - struct sockaddr_storage addr_storage; const unsigned short port = args[3].As()->Value(); node::Utf8Value address(env->isolate(), args[4]); err = sockaddr_for_family(family, address.out(), port, &addr_storage);