From 635bf5a6b2f5ff87095f4350cea6f6f4e192d14f Mon Sep 17 00:00:00 2001 From: James Keast Date: Fri, 10 Feb 2023 15:24:15 -0400 Subject: [PATCH] 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 --- lib/setopt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 */ -- 2.47.2