win: fix free() on bad input in uv_getaddrinfo()

The error path frees `req->alloc` but that hasn't been set yet when
`service` and `node` are both NULL.  Simply return instead of jumping
to the error handling block.

Fixes: https://github.com/libuv/libuv/issues/1122
PR-URL: https://github.com/libuv/libuv/pull/1123
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
This commit is contained in:
Ben Noordhuis 2016-11-04 00:21:04 +01:00 committed by cjihrig
parent 11ce5df5ea
commit 7bfb5ae7f9
2 changed files with 8 additions and 2 deletions

View File

@ -262,8 +262,7 @@ int uv_getaddrinfo(uv_loop_t* loop,
int err;
if (req == NULL || (node == NULL && service == NULL)) {
err = WSAEINVAL;
goto error;
return UV_EINVAL;
}
uv_req_init(loop, (uv_req_t*)req);

View File

@ -83,6 +83,13 @@ static void getaddrinfo_cuncurrent_cb(uv_getaddrinfo_t* handle,
TEST_IMPL(getaddrinfo_fail) {
uv_getaddrinfo_t req;
ASSERT(UV_EINVAL == uv_getaddrinfo(uv_default_loop(),
&req,
(uv_getaddrinfo_cb) abort,
NULL,
NULL,
NULL));
/* Use a FQDN by ending in a period */
ASSERT(0 == uv_getaddrinfo(uv_default_loop(),
&req,