]> granicus.if.org Git - curl/commitdiff
http_proxy: avoid freeing static memory
authorDaniel Stenberg <daniel@haxx.se>
Thu, 9 Feb 2017 09:13:28 +0000 (10:13 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Thu, 9 Feb 2017 09:13:28 +0000 (10:13 +0100)
Follow up to 7fe81ec298e0: make sure 'host' is either NULL or malloced.

lib/http_proxy.c

index ac1b3bf93ecf9488f5e46a100498afed0ec183d1..d523ba519108670335b48768bbbce9cdf50f60d1 100644 (file)
@@ -5,7 +5,7 @@
  *                            | (__| |_| |  _ <| |___
  *                             \___|\___/|_| \_\_____|
  *
- * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
  *
  * This software is licensed as described in the file COPYING, which
  * you should have received as part of this distribution. The terms
@@ -199,7 +199,7 @@ CURLcode Curl_proxyCONNECT(struct connectdata *conn,
       free(host_port);
 
       if(!result) {
-        char *host=(char *)"";
+        char *host = NULL;
         const char *proxyconn="";
         const char *useragent="";
         const char *http = (conn->http_proxy.proxytype == CURLPROXY_HTTP_1_0) ?
@@ -242,7 +242,7 @@ CURLcode Curl_proxyCONNECT(struct connectdata *conn,
                            "%s", /* Proxy-Connection */
                            hostheader,
                            http,
-                           host,
+                           host?host:"",
                            conn->allocptr.proxyuserpwd?
                            conn->allocptr.proxyuserpwd:"",
                            useragent,