aboutsummaryrefslogtreecommitdiff
path: root/ares
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2004-05-27 06:42:48 +0000
committerDaniel Stenberg <daniel@haxx.se>2004-05-27 06:42:48 +0000
commitff0429a802365250d4e47df718f431284c023aa8 (patch)
tree90d7a0a3fdade93f8aff11d9084c011ac490be07 /ares
parent46cdc83b81f071ac250e5d4530228fa3728f3ded (diff)
James Bursa's fix to prevent free(NULL) to occur
Diffstat (limited to 'ares')
-rw-r--r--ares/ares__get_hostent.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/ares/ares__get_hostent.c b/ares/ares__get_hostent.c
index ecba75c92..f05d71299 100644
--- a/ares/ares__get_hostent.c
+++ b/ares/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;
}