From 7813d9a077b3e0723a9fb82676957e81f351368b Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Sun, 5 Apr 2026 14:46:40 +0200 Subject: [PATCH] share: do bitshifts after the type is checked to be valid Fixes #21224 Reported-by: bird on github Closes #21226 --- lib/curl_share.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/curl_share.c b/lib/curl_share.c index 94d53e8911..386a2b547d 100644 --- a/lib/curl_share.c +++ b/lib/curl_share.c @@ -281,7 +281,6 @@ CURLSHcode curl_share_setopt(CURLSH *sh, CURLSHoption option, ...) case CURLSHOPT_UNSHARE: /* this is a type this share will no longer share */ type = va_arg(param, int); - share->specifier &= ~(unsigned int)(1 << type); switch(type) { case CURL_LOCK_DATA_DNS: break; @@ -325,6 +324,8 @@ CURLSHcode curl_share_setopt(CURLSH *sh, CURLSHoption option, ...) res = CURLSHE_BAD_OPTION; break; } + if(!res) + share->specifier &= ~(unsigned int)(1 << type); break; case CURLSHOPT_LOCKFUNC: