summaryrefslogtreecommitdiff
path: root/ares__get_hostent.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2004-05-27 07:09:21 (GMT)
committerDaniel Stenberg <daniel@haxx.se>2004-05-27 07:09:21 (GMT)
commit8cb7fd4e2223ba1893dd57fade2cf8e8d38e0bb7 (patch)
tree4172a5687d6b5b2b5279a87025fb6abf0e455de1 /ares__get_hostent.c
parentd870be584d57130accf54602383c8325123fce4d (diff)
downloadc-ares-8cb7fd4e2223ba1893dd57fade2cf8e8d38e0bb7.zip
c-ares-8cb7fd4e2223ba1893dd57fade2cf8e8d38e0bb7.tar.gz
c-ares-8cb7fd4e2223ba1893dd57fade2cf8e8d38e0bb7.tar.bz2
better checks to avoid free(NULL)
Diffstat (limited to 'ares__get_hostent.c')
-rw-r--r--ares__get_hostent.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/ares__get_hostent.c b/ares__get_hostent.c
index f05d712..bf99627 100644
--- a/ares__get_hostent.c
+++ b/ares__get_hostent.c
@@ -140,11 +140,11 @@ int ares__get_hostent(FILE *fp, struct hostent **host)
memcpy(hostent->h_addr_list[0], &addr, sizeof(struct in_addr));
hostent->h_addr_list[1] = NULL;
*host = hostent;
- if(line)
- free(line);
+ free(line);
return ARES_SUCCESS;
}
- free(line);
+ if(line)
+ free(line);
if (status == ARES_SUCCESS)
{
@@ -160,7 +160,7 @@ int ares__get_hostent(FILE *fp, struct hostent **host)
}
if(hostent->h_aliases)
free(hostent->h_aliases);
- if (hostent->h_addr_list)
+ if (hostent->h_addr_list && hostent->h_addr_list[0])
free(hostent->h_addr_list[0]);
if(hostent->h_addr_list)
free(hostent->h_addr_list);