From 3267d9f2570a52e3fde3f0484520eba731b32094 Mon Sep 17 00:00:00 2001 From: cjihrig Date: Fri, 15 Jan 2016 16:54:13 -0500 Subject: [PATCH] src: return UV_EAI_NODATA on empty lookup AfterGetAddrInfo() can potentially return an empty array of results without setting an error value. The JavaScript layer expects the array to have at least one value if an error is not returned. This commit sets a UV_EAI_NODATA error when an empty result array is detected. Fixes: https://github.com/nodejs/node/issues/4545 --- src/cares_wrap.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/cares_wrap.cc b/src/cares_wrap.cc index 8f57dfe477cda4..46636c528b7f81 100644 --- a/src/cares_wrap.cc +++ b/src/cares_wrap.cc @@ -983,6 +983,10 @@ void AfterGetAddrInfo(uv_getaddrinfo_t* req, int status, struct addrinfo* res) { address = address->ai_next; } + // No responses were found to return + if (n == 0) { + argv[0] = Integer::New(env->isolate(), UV_EAI_NODATA); + } argv[1] = results; }