setopt: Address undefined behaviour by checking for null

This addresses undefined behaviour found using clang's UBsan:

curl/lib/setopt.c:177:14: runtime error: applying non-zero offset 1 to null pointer
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior curl/lib/setopt.c:177:14 in

Closes #10472
This commit is contained in:
James Keast 2023-02-10 15:24:15 -04:00 committed by Dan Fandrich
parent 38262c944d
commit 635bf5a6b2

View File

@ -174,7 +174,7 @@ static CURLcode protocol2num(const char *str, curl_prot_t *val)
*val |= h->protocol;
}
} while(str++);
} while(str && str++);
if(!*val)
/* no protocol listed */