tool_operate: free 'gateway' correctly

Pointed out by Coverity. The fix in 93885cf3a8 was incomplete.

Also removed repeated wording in IPFS related error messages.

Closes #11969
This commit is contained in:
Daniel Stenberg 2023-09-28 09:32:39 +02:00
parent 0bd9e137e3
commit a35e2dd69c
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2

View File

@ -857,34 +857,29 @@ static CURLcode ipfs_url_rewrite(CURLU *uh, const char *protocol, char **url,
result = CURLE_OK;
clean:
curl_free(gateway);
free(gateway);
curl_free(cid);
curl_free(pathbuffer);
if(ipfsurl) {
curl_url_cleanup(ipfsurl);
}
curl_url_cleanup(ipfsurl);
switch(result) {
case CURLE_URL_MALFORMAT:
helpf(stderr, "malformed URL. Visit https://curl.se/"
"docs/ipfs.html#Gateway-file-and-"
"environment-variable for more "
"information for more information");
"information");
break;
case CURLE_FILE_COULDNT_READ_FILE:
helpf(stderr, "IPFS automatic gateway detection "
"failure. Visit https://curl.se/docs/"
"ipfs.html#Malformed-gateway-URL for "
"more information for more "
"information");
"more information");
break;
case CURLE_BAD_FUNCTION_ARGUMENT:
helpf(stderr, "--ipfs-gateway argument results in "
"malformed URL. Visit https://curl.se/"
"docs/ipfs.html#Malformed-gateway-URL "
"for more information for more "
"information");
"for more information");
break;
default:
break;