Skip to content

Commit

Permalink
ares_init.c: fix segfault triggered in ares_init_options() upon previous
Browse files Browse the repository at this point in the history
             failure of init_by_defaults() and incomplete cleanup there.
  • Loading branch information
yangtse committed Sep 6, 2011
1 parent 66e9143 commit 3d84eb3
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions ares_init.c
Expand Up @@ -1249,15 +1249,22 @@ static int init_by_defaults(ares_channel channel)

error:
if(rc) {
if(channel->servers)
if(channel->servers) {
free(channel->servers);
channel->servers = NULL;
}

if(channel->domains && channel->domains[0])
free(channel->domains[0]);
if(channel->domains)
if(channel->domains) {
free(channel->domains);
if(channel->lookups)
channel->domains = NULL;
}

if(channel->lookups) {
free(channel->lookups);
channel->lookups = NULL;
}
}

if(hostname)
Expand Down

0 comments on commit 3d84eb3

Please sign in to comment.