summaryrefslogtreecommitdiff
path: root/ares__get_hostent.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2004-05-27 06:42:48 (GMT)
committerDaniel Stenberg <daniel@haxx.se>2004-05-27 06:42:48 (GMT)
commitd870be584d57130accf54602383c8325123fce4d (patch)
tree0bc1e9bace3ca0dc17391e0d4a78d50b1b5d5d00 /ares__get_hostent.c
parent44f76e6a273936c171bfbe3927a3aeff18d606a3 (diff)
downloadc-ares-d870be584d57130accf54602383c8325123fce4d.zip
c-ares-d870be584d57130accf54602383c8325123fce4d.tar.gz
c-ares-d870be584d57130accf54602383c8325123fce4d.tar.bz2
James Bursa's fix to prevent free(NULL) to occur
Diffstat (limited to 'ares__get_hostent.c')
-rw-r--r--ares__get_hostent.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/ares__get_hostent.c b/ares__get_hostent.c
index ecba75c..f05d712 100644
--- a/ares__get_hostent.c
+++ b/ares__get_hostent.c
@@ -140,7 +140,8 @@ 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;
- free(line);
+ if(line)
+ free(line);
return ARES_SUCCESS;
}
free(line);
@@ -150,18 +151,21 @@ int ares__get_hostent(FILE *fp, struct hostent **host)
/* Memory allocation failure; clean up. */
if (hostent)
{
- free((char *) hostent->h_name);
+ if(hostent->h_name)
+ free((char *) hostent->h_name);
if (hostent->h_aliases)
{
for (alias = hostent->h_aliases; *alias; alias++)
free(*alias);
}
- free(hostent->h_aliases);
+ if(hostent->h_aliases)
+ free(hostent->h_aliases);
if (hostent->h_addr_list)
free(hostent->h_addr_list[0]);
- free(hostent->h_addr_list);
+ if(hostent->h_addr_list)
+ free(hostent->h_addr_list);
+ free(hostent);
}
- free(hostent);
return ARES_ENOMEM;
}