From: James Keast Date: Fri, 10 Feb 2023 19:24:15 +0000 (-0400) Subject: setopt: Address undefined behaviour by checking for null X-Git-Tag: curl-7_88_0~20 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=635bf5a6b2f5ff87095f4350cea6f6f4e192d14f;p=thirdparty%2Fcurl.git 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 --- diff --git a/lib/setopt.c b/lib/setopt.c index b8c639847a..b8fa1b89e6 100644 --- a/lib/setopt.c +++ b/lib/setopt.c @@ -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 */