Index: lib/http.c
===================================================================
RCS file: /cvsroot/curl/curl/lib/http.c,v
retrieving revision 1.238
diff -u -r1.238 http.c
--- lib/http.c	1 Jul 2004 07:30:19 -0000	1.238
+++ lib/http.c	26 Jul 2004 15:19:58 -0000
@@ -1351,6 +1351,8 @@
     }
   }
 
+  Curl_safefree(conn->allocptr.host);
+
   ptr = checkheaders(data, "Host:");
   if(ptr && !data->state.this_is_a_follow) {
     /* If we have a given custom Host: header, we extract the host name in
@@ -1374,10 +1376,10 @@
       memcpy(conn->allocptr.cookiehost, start, len);
       conn->allocptr.cookiehost[len]=0;
     }
+
+    conn->allocptr.host = NULL;
   }
   else {
-    Curl_safefree(conn->allocptr.host);
-
     /* When building Host: headers, we must put the host name within
        [brackets] if the host name is a plain IPv6-address. RFC2732-style. */
 
