urlapi: avoid mutating internals in getter routine

This was not intended.

Closes #10708
This commit is contained in:
rcombs 2023-03-08 02:12:25 -06:00 committed by Daniel Stenberg
parent 0a0c9b6dfa
commit 95cb7d3166
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2

View File

@ -1441,11 +1441,8 @@ CURLUcode curl_url_get(CURLU *u, CURLUPart what,
break;
case CURLUPART_PATH:
ptr = u->path;
if(!ptr) {
ptr = u->path = strdup("/");
if(!u->path)
return CURLUE_OUT_OF_MEMORY;
}
if(!ptr)
ptr = "/";
break;
case CURLUPART_QUERY:
ptr = u->query;
@ -1555,8 +1552,7 @@ CURLUcode curl_url_get(CURLU *u, CURLUPart what,
return CURLUE_OUT_OF_MEMORY;
host++;
}
free(u->host);
u->host = Curl_dyn_ptr(&enc);
allochost = Curl_dyn_ptr(&enc);
}
}