2
0
mirror of https://github.com/curl/curl.git synced 2025-02-23 15:10:03 +08:00

tool_operate: fix potential memory-leak

A 'CURLU *' would leak if url_proto() is called with no URL.

Detected by Coverity. CID 1494643.
Follow-up to 18270893ab
Closes 
This commit is contained in:
Daniel Stenberg 2021-12-06 08:25:56 +01:00
parent a40160aee8
commit 75b31ce626
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2

View File

@ -668,6 +668,7 @@ static long url_proto(char *url)
{
CURLU *uh = curl_url();
long proto = 0;
if(uh) {
if(url) {
if(!curl_url_set(uh, CURLUPART_URL, url,
CURLU_GUESS_SCHEME | CURLU_NON_SUPPORT_SCHEME)) {
@ -679,6 +680,7 @@ static long url_proto(char *url)
curl_free(schemep);
}
}
}
curl_url_cleanup(uh);
}
return proto;