urlapi: avoid null deref if setting blank host to url encode

Reported-by: kirbyn17 on hackerone

Closes #12240
This commit is contained in:
Daniel Stenberg 2023-10-31 11:24:13 +01:00
parent 27f2352d49
commit c64d0d67fd
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2

View File

@ -1931,8 +1931,8 @@ nomem:
}
}
if(what == CURLUPART_HOST) {
size_t n = strlen(newp);
else if(what == CURLUPART_HOST) {
size_t n = Curl_dyn_len(&enc);
if(!n && (flags & CURLU_NO_AUTHORITY)) {
/* Skip hostname check, it's allowed to be empty. */
}