ares_init.c: fix segfault triggered in ares_init_options() upon previous
authorYang Tse <yangsita@gmail.com>
Tue, 6 Sep 2011 22:30:53 +0000 (00:30 +0200)
committerYang Tse <yangsita@gmail.com>
Tue, 6 Sep 2011 22:30:53 +0000 (00:30 +0200)
             failure of init_by_defaults() and incomplete cleanup there.

ares_init.c

index dd59fed..0c1d545 100644 (file)
@@ -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)