curl: improved cleanup in upload error path

Memory leak found by torture test 58

Closes #4705
This commit is contained in:
Daniel Stenberg 2019-12-11 11:16:12 +01:00
parent 5a1b0f4c5b
commit dc4900eea7
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2

View File

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