]> granicus.if.org Git - curl/commitdiff
url: fix the NULL hostname compiler warning case
authorJay Satiro <raysatiro@yahoo.com>
Wed, 25 Sep 2019 12:35:02 +0000 (14:35 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Wed, 25 Sep 2019 12:35:02 +0000 (14:35 +0200)
Closes #4403

lib/url.c

index e4c47930a54a22d8424227cfed660a68c8f282d2..14e6e262590f3d749c9148993655ac57116bf41a 100644 (file)
--- a/lib/url.c
+++ b/lib/url.c
@@ -1870,11 +1870,7 @@ static CURLcode parseurlandfillconn(struct Curl_easy *data,
   (void)curl_url_get(uh, CURLUPART_QUERY, &data->state.up.query, 0);
 
   hostname = data->state.up.hostname;
-  if(!hostname)
-    /* this is for file:// transfers, get a dummy made */
-    hostname = (char *)"";
-
-  if(hostname[0] == '[') {
+  if(hostname && hostname[0] == '[') {
     /* This looks like an IPv6 address literal. See if there is an address
        scope. */
     size_t hlen;
@@ -1888,7 +1884,7 @@ static CURLcode parseurlandfillconn(struct Curl_easy *data,
   }
 
   /* make sure the connect struct gets its own copy of the host name */
-  conn->host.rawalloc = strdup(hostname);
+  conn->host.rawalloc = strdup(hostname ? hostname : "");
   if(!conn->host.rawalloc)
     return CURLE_OUT_OF_MEMORY;
   conn->host.name = conn->host.rawalloc;