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 #8098
This commit is contained in:
Родитель
a40160aee8
Коммит
75b31ce626
|
@ -668,15 +668,17 @@ static long url_proto(char *url)
|
|||
{
|
||||
CURLU *uh = curl_url();
|
||||
long proto = 0;
|
||||
if(url) {
|
||||
if(!curl_url_set(uh, CURLUPART_URL, url,
|
||||
CURLU_GUESS_SCHEME | CURLU_NON_SUPPORT_SCHEME)) {
|
||||
char *schemep = NULL;
|
||||
if(!curl_url_get(uh, CURLUPART_SCHEME, &schemep,
|
||||
CURLU_DEFAULT_SCHEME) &&
|
||||
schemep) {
|
||||
proto = scheme2protocol(schemep);
|
||||
curl_free(schemep);
|
||||
if(uh) {
|
||||
if(url) {
|
||||
if(!curl_url_set(uh, CURLUPART_URL, url,
|
||||
CURLU_GUESS_SCHEME | CURLU_NON_SUPPORT_SCHEME)) {
|
||||
char *schemep = NULL;
|
||||
if(!curl_url_get(uh, CURLUPART_SCHEME, &schemep,
|
||||
CURLU_DEFAULT_SCHEME) &&
|
||||
schemep) {
|
||||
proto = scheme2protocol(schemep);
|
||||
curl_free(schemep);
|
||||
}
|
||||
}
|
||||
}
|
||||
curl_url_cleanup(uh);
|
||||
|
|
Загрузка…
Ссылка в новой задаче