mirror of
https://github.com/neovim/neovim.git
synced 2025-09-29 22:48:34 +00:00
Server: Call uv_getaddrinfo with NULL service when no port
When using serverstart("ip.ad.d.r:") to listen on a random port, we need to abide by getaddrinfo()'s API and pass in a NULL service, rather than an empty string. When given an empty string, getaddrinfo() is free to search for a service by the given name (since the string isn't a number) which will fail. At least FreeBSD does perform this lookup.
This commit is contained in:
@@ -45,6 +45,12 @@ int socket_watcher_init(Loop *loop, SocketWatcher *watcher,
|
||||
return UV_EINVAL;
|
||||
}
|
||||
|
||||
if (*port == NUL) {
|
||||
// When no port is given, (uv_)getaddrinfo expects NULL otherwise the
|
||||
// implementation may attempt to lookup the service by name (and fail)
|
||||
port = NULL;
|
||||
}
|
||||
|
||||
uv_getaddrinfo_t request;
|
||||
|
||||
int retval = uv_getaddrinfo(&loop->uv, &request, NULL, addr, port,
|
||||
|
Reference in New Issue
Block a user