summaryrefslogtreecommitdiff
path: root/deps/uv/src/win/getnameinfo.c
diff options
context:
space:
mode:
Diffstat (limited to 'deps/uv/src/win/getnameinfo.c')
-rw-r--r--deps/uv/src/win/getnameinfo.c49
1 files changed, 28 insertions, 21 deletions
diff --git a/deps/uv/src/win/getnameinfo.c b/deps/uv/src/win/getnameinfo.c
index 9f10cd2a5a..71785a9fa6 100644
--- a/deps/uv/src/win/getnameinfo.c
+++ b/deps/uv/src/win/getnameinfo.c
@@ -42,7 +42,7 @@ static void uv__getnameinfo_work(struct uv__work* w) {
uv_getnameinfo_t* req;
WCHAR host[NI_MAXHOST];
WCHAR service[NI_MAXSERV];
- int ret = 0;
+ int ret;
req = container_of(w, uv_getnameinfo_t, work_req);
if (GetNameInfoW((struct sockaddr*)&req->storage,
@@ -53,27 +53,34 @@ static void uv__getnameinfo_work(struct uv__work* w) {
ARRAY_SIZE(service),
req->flags)) {
ret = WSAGetLastError();
+ req->retcode = uv__getaddrinfo_translate_error(ret);
+ return;
+ }
+
+ ret = WideCharToMultiByte(CP_UTF8,
+ 0,
+ host,
+ -1,
+ req->host,
+ sizeof(req->host),
+ NULL,
+ NULL);
+ if (ret == 0) {
+ req->retcode = uv_translate_sys_error(GetLastError());
+ return;
+ }
+
+ ret = WideCharToMultiByte(CP_UTF8,
+ 0,
+ service,
+ -1,
+ req->service,
+ sizeof(req->service),
+ NULL,
+ NULL);
+ if (ret == 0) {
+ req->retcode = uv_translate_sys_error(GetLastError());
}
- req->retcode = uv__getaddrinfo_translate_error(ret);
-
- /* convert results to UTF-8 */
- WideCharToMultiByte(CP_UTF8,
- 0,
- host,
- -1,
- req->host,
- sizeof(req->host),
- NULL,
- NULL);
-
- WideCharToMultiByte(CP_UTF8,
- 0,
- service,
- -1,
- req->service,
- sizeof(req->service),
- NULL,
- NULL);
}