urlapi: make curl_url_set(url, CURLUPART_URL, NULL, 0) clear all parts

As per the documentation :

> Setting a part to a NULL pointer will effectively remove that
> part's contents from the CURLU handle.

But currently clearing CURLUPART_URL does nothing and returns
CURLUE_OK. This change will clear all parts of the URL at once.

Closes #9028
This commit is contained in:
Pierrick Charron 2022-06-19 10:54:04 -04:00 committed by Daniel Stenberg
parent 06fc958305
commit 4bf2c231d7
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
2 changed files with 62 additions and 0 deletions

View file

@ -1518,6 +1518,10 @@ CURLUcode curl_url_set(CURLU *u, CURLUPart what,
if(storep && *storep) {
Curl_safefree(*storep);
}
else if(!storep) {
free_urlhandle(u);
memset(u, 0, sizeof(struct Curl_URL));
}
return CURLUE_OK;
}