From fefc7ea6008c48cbc3c346da4da55169da8c3adc Mon Sep 17 00:00:00 2001
From: Daniel Stenberg <daniel@haxx.se>
Date: Mon, 14 Jan 2002 23:14:24 +0000
Subject: a memory leak when name lookup failed is now removed

---
 lib/hostip.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

(limited to 'lib')

diff --git a/lib/hostip.c b/lib/hostip.c
index 829188c49..1f3b850e2 100644
--- a/lib/hostip.c
+++ b/lib/hostip.c
@@ -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;
-- 
cgit v1.2.3