Fix logic error that can result in a potential crash (when getaddrinfo() fails

and res happened to be NULL).

Also add missing freeaddrinfo() call.


git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@188 13b04d17-f746-0410-82c6-800466cd88b0
This commit is contained in:
Kevin Easton
2012-05-15 13:29:32 +00:00
parent 9ec4f49540
commit ba365bfd54
2 changed files with 4 additions and 1 deletions

View File

@@ -639,10 +639,11 @@ int lame_resolv (const char *hostname, struct sockaddr_foobar *buffer)
{
#ifdef IPV6
struct addrinfo *res;
if (getaddrinfo(hostname, NULL, NULL, &res) && res)
if (getaddrinfo(hostname, NULL, NULL, &res) || !res)
return -1;
memmove(buffer, res->ai_addr, res->ai_addrlen);
freeaddrinfo(res);
return 0;
#else
struct hostent *hp;