diff --git a/src/unix/tcp.c b/src/unix/tcp.c index 9f14c1b6..8c3b27b8 100644 --- a/src/unix/tcp.c +++ b/src/unix/tcp.c @@ -226,12 +226,7 @@ int uv_tcp_connect(uv_connect_t* req, saved_errno = errno; status = -1; - if (handle->type != UV_TCP) { - uv_err_new(handle->loop, EINVAL); - goto out; - } - - if (address.sin_family != AF_INET) { + if (handle->type != UV_TCP || address.sin_family != AF_INET) { uv_err_new(handle->loop, EINVAL); goto out; } @@ -258,12 +253,7 @@ int uv_tcp_connect6(uv_connect_t* req, saved_errno = errno; status = -1; - if (handle->type != UV_TCP) { - uv_err_new(handle->loop, EINVAL); - goto out; - } - - if (address.sin6_family != AF_INET6) { + if (handle->type != UV_TCP || address.sin6_family != AF_INET6) { uv_err_new(handle->loop, EINVAL); goto out; } diff --git a/src/win/tcp.c b/src/win/tcp.c index 783d5fb9..d909eb30 100644 --- a/src/win/tcp.c +++ b/src/win/tcp.c @@ -484,7 +484,7 @@ int uv_tcp_connect(uv_connect_t* req, uv_tcp_t* handle, return -1; } - if (address.sin_family != AF_INET) { + if (handle->type != UV_TCP || address.sin_family != AF_INET) { uv_set_sys_error(loop, WSAEFAULT); return -1; } @@ -540,7 +540,7 @@ int uv_tcp_connect6(uv_connect_t* req, uv_tcp_t* handle, return -1; } - if (address.sin6_family != AF_INET6) { + if (handle->type != UV_TCP || address.sin6_family != AF_INET6) { uv_set_sys_error(loop, WSAEFAULT); return -1; }