Revert "ares_parse_aaaa_reply: fix leak when reply contains 1 alias and no address"

This reverts commit 440110b303.
pull/15/head
Daniel Stenberg 11 years ago
parent 440110b303
commit 0004f498dc
  1. 3
      ares_free_hostent.c
  2. 8
      ares_parse_aaaa_reply.c

@ -34,8 +34,7 @@ void ares_free_hostent(struct hostent *host)
for (p = host->h_aliases; *p; p++)
free(*p);
free(host->h_aliases);
if (host->h_addr_list[0])
free(host->h_addr_list[0]); /* no matter if there is one or many entries,
free(host->h_addr_list[0]); /* no matter if there is one or many entries,
there is only one malloc for all of them */
free(host->h_addr_list);
free(host);

@ -239,12 +239,8 @@ int ares_parse_aaaa_reply(const unsigned char *abuf, int alen,
hostent->h_aliases = aliases;
hostent->h_addrtype = AF_INET6;
hostent->h_length = sizeof(struct ares_in6_addr);
if (naddrs) {
for (i = 0; i < naddrs; i++)
hostent->h_addr_list[i] = (char *) &addrs[i];
} else {
free(addrs);
}
for (i = 0; i < naddrs; i++)
hostent->h_addr_list[i] = (char *) &addrs[i];
hostent->h_addr_list[naddrs] = NULL;
if (!naddrs && addrs)
free(addrs);

Loading…
Cancel
Save