]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
curl: improved cleanup in upload error path
authorDaniel Stenberg <daniel@haxx.se>
Wed, 11 Dec 2019 10:16:12 +0000 (11:16 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Thu, 12 Dec 2019 08:23:45 +0000 (09:23 +0100)
Memory leak found by torture test 58

Closes #4705

src/tool_operhlp.c

index 543bf430256d9db7ea9ca0487313382ac628f3d3..8a9b7c9e8fd3557fec1669f7a726fc3dca213abc 100644 (file)
@@ -115,16 +115,17 @@ char *add_file_name_to_url(char *url, const char *filename)
         urlbuffer = aprintf("%s/%s", url, encfile);
 
       curl_free(encfile);
-      Curl_safefree(url);
 
-      if(!urlbuffer)
-        return NULL;
+      if(!urlbuffer) {
+        url = NULL;
+        goto end;
+      }
 
+      Curl_safefree(url);
       url = urlbuffer; /* use our new URL instead! */
     }
-    else
-      Curl_safefree(url);
   }
+  end:
   curl_easy_cleanup(curl);
   return url;
 }