mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Always call freeaddrinfo
This commit is contained in:
parent
79aeb5ea38
commit
55bfd2cf01
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue