Always call freeaddrinfo

This commit is contained in:
def 2014-12-28 01:40:15 +01:00
parent 79aeb5ea38
commit 55bfd2cf01

View file

@ -900,7 +900,7 @@ static int priv_net_extract(const char *hostname, char *host, int max_host, int
int net_host_lookup(const char *hostname, NETADDR *addr, int types)
{
struct addrinfo hints;
struct addrinfo *result;
struct addrinfo *result = NULL;
int e;
char host[256];
int port = 0;
@ -921,9 +921,15 @@ int net_host_lookup(const char *hostname, NETADDR *addr, int types)
e = getaddrinfo(host, NULL, &hints, &result);
if(!result || e != 0)
if(!result)
return -1;
if(e != 0)
{
freeaddrinfo(result);
return -1;
}
sockaddr_to_netaddr(result->ai_addr, addr);
addr->port = port;
freeaddrinfo(result);