]> granicus.if.org Git - curl/commitdiff
a memory leak when name lookup failed is now removed
authorDaniel Stenberg <daniel@haxx.se>
Mon, 14 Jan 2002 23:14:24 +0000 (23:14 +0000)
committerDaniel Stenberg <daniel@haxx.se>
Mon, 14 Jan 2002 23:14:24 +0000 (23:14 +0000)
lib/hostip.c

index 829188c495388706bd4e5996973729a1b8f67986..1f3b850e2a577ec3a283cab362da5d9a38e64053 100644 (file)
@@ -131,13 +131,14 @@ Curl_addrinfo *Curl_resolv(struct SessionHandle *data,
   }
 
   /* Create a new cache entry */
-  p = (struct curl_dns_cache_entry *) malloc(sizeof(struct curl_dns_cache_entry));
-  if (!p) {
+  p = (struct curl_dns_cache_entry *)
+    malloc(sizeof(struct curl_dns_cache_entry));
+  if (!p)
     return NULL;
-  }
 
   p->addr = Curl_getaddrinfo(data, hostname, port, bufp);
   if (!p->addr) {
+    free(p);
     return NULL;
   }
   p->timestamp = now;