From 5ba93cf433452c3e3d56d6460fc66d728c1f9ea3 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Sat, 16 May 2026 13:06:49 +0200 Subject: [PATCH] curl_share.c try to defeat clang-tidy MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ``` /home/runner/work/curl/curl/lib/curl_setup.h:1650:7: error: check of ‘share’ for NULL after already dereferencing it [-Werror=analyzer-deref-before-check] 1650 | if(ptr) \ | ^ /home/runner/work/curl/curl/lib/curl_share.c:64:3: note: in expansion of macro ‘curlx_memzero’ 64 | curlx_memzero(share, sizeof(*share)); | ^~~~~~~~~~~~~ ‘share_destroy’: events 1-3 | | 37 | if(share->specifier & (1 << CURL_LOCK_DATA_CONNECT)) { | | ~~~~~^~~~~~~~~~~ | | | | | (1) pointer ‘share’ is dereferenced here |...... | 52 | if(share->ssl_scache) { | | ~ | | | | | (2) following ‘false’ branch... |...... | 58 | Curl_psl_destroy(&share->psl); | | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | | | (3) ...to here | ‘share_destroy’: event 4 | |/home/runner/work/curl/curl/lib/curl_setup.h:1650:7: | 1650 | if(ptr) \ | | ^ | | | | | (4) pointer ‘share’ is checked for NULL here but it was already dereferenced at (1) /home/runner/work/curl/curl/lib/curl_share.c:64:3: note: in expansion of macro ‘curlx_memzero’ | 64 | curlx_memzero(share, sizeof(*share)); | | ^~~~~~~~~~~~~ | ``` https://github.com/curl/curl/actions/runs/25960248795/job/76314218955?pr=21637 --- lib/curl_share.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/curl_share.c b/lib/curl_share.c index 0b4ee9e367..b7c331adf7 100644 --- a/lib/curl_share.c +++ b/lib/curl_share.c @@ -34,6 +34,9 @@ static void share_destroy(struct Curl_share *share) { + if(!share) + return; + if(share->specifier & (1 << CURL_LOCK_DATA_CONNECT)) { Curl_cpool_destroy(&share->cpool); }