]> granicus.if.org Git - curl/commitdiff
smb: fix memory-leak in URL parse error path
authorDaniel Stenberg <daniel@haxx.se>
Thu, 12 Jul 2018 09:44:57 +0000 (11:44 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Thu, 12 Jul 2018 12:47:11 +0000 (14:47 +0200)
Detected by OSS-Fuzz
Bug: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=9369
Closes #2740

lib/smb.c

index 9ac61505cf441a0b42dc0089e85b94f763d07b1b..fad63625214165aae31f9bc57b19fa21c04124b9 100644 (file)
--- a/lib/smb.c
+++ b/lib/smb.c
@@ -969,11 +969,9 @@ static CURLcode smb_parse_url_path(struct connectdata *conn)
 
   /* Parse the path for the share */
   req->share = strdup((*path == '/' || *path == '\\') ? path + 1 : path);
-  if(!req->share) {
-    free(path);
-
+  free(path);
+  if(!req->share)
     return CURLE_OUT_OF_MEMORY;
-  }
 
   slash = strchr(req->share, '/');
   if(!slash)
@@ -981,8 +979,7 @@ static CURLcode smb_parse_url_path(struct connectdata *conn)
 
   /* The share must be present */
   if(!slash) {
-    free(path);
-
+    Curl_safefree(req->share);
     return CURLE_URL_MALFORMAT;
   }
 
@@ -995,8 +992,6 @@ static CURLcode smb_parse_url_path(struct connectdata *conn)
       *slash = '\\';
   }
 
-  free(path);
-
   return CURLE_OK;
 }