tool_operate: fix memory-leak on failed uploads

Add test case 1673 to do repeated upload failures and verify there is no
leak. This proved a previous leak and now it verifies the fix.

Reported-by: James Fuller
Closes #21062
This commit is contained in:
Daniel Stenberg 2026-03-22 13:08:43 +01:00
parent e8c64a06c5
commit 9820e5dfac
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
3 changed files with 30 additions and 5 deletions

View file

@ -235,6 +235,10 @@ static struct per_transfer *del_per_transfer(struct per_transfer *per)
else
transfersl = p;
curlx_free(per->uploadfile);
curlx_free(per->outfile);
curlx_free(per->url);
curl_easy_cleanup(per->curl);
curlx_free(per);
return n;
@ -777,12 +781,8 @@ static CURLcode post_per_transfer(struct per_transfer *per,
if(per->etag_save.alloc_filename)
tool_safefree(per->etag_save.filename);
curl_easy_cleanup(per->curl);
if(outs->alloc_filename)
curlx_free(outs->filename);
curlx_free(per->url);
curlx_free(per->outfile);
curlx_free(per->uploadfile);
curl_slist_free_all(per->hdrcbdata.headlist);
per->hdrcbdata.headlist = NULL;
return result;