From: Daniel Stenberg Date: Wed, 11 Dec 2019 10:16:12 +0000 (+0100) Subject: curl: improved cleanup in upload error path X-Git-Tag: curl-7_68_0~77 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=dc4900eea7317c67116fd5e6cd31863775da88ed;p=thirdparty%2Fcurl.git curl: improved cleanup in upload error path Memory leak found by torture test 58 Closes #4705 --- diff --git a/src/tool_operhlp.c b/src/tool_operhlp.c index 543bf43025..8a9b7c9e8f 100644 --- a/src/tool_operhlp.c +++ b/src/tool_operhlp.c @@ -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; }