Skip to content

Commit

Permalink
src: return UV_EAI_NODATA on empty lookup
Browse files Browse the repository at this point in the history
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: #4545
PR-URL: #4715
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: Evan Lucas <[email protected]>
Reviewed-By: Saúl Ibarra Corretgé <[email protected]>
  • Loading branch information
cjihrig committed Jan 18, 2016
1 parent 761cf2b commit 8bad519
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/cares_wrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 8bad519

Please sign in to comment.