From: Daniel Stenberg Date: Wed, 7 May 2025 08:49:13 +0000 (+0200) Subject: metahash: add asserts to help analyzers X-Git-Tag: curl-8_14_0~147 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cf38e0067cd291fac872c555abd46d9d91b7f2e8;p=thirdparty%2Fcurl.git metahash: add asserts to help analyzers Where NULL pointers are not acceptable input. Closes #17268 --- diff --git a/lib/easy.c b/lib/easy.c index 67064f2bc2..4dab47284a 100644 --- a/lib/easy.c +++ b/lib/easy.c @@ -1390,6 +1390,7 @@ CURLcode curl_easy_ssls_export(CURL *d, CURLcode Curl_meta_set(struct Curl_easy *data, const char *key, void *meta_data, Curl_meta_dtor *meta_dtor) { + DEBUGASSERT(meta_data); /* never set to NULL */ if(!Curl_hash_add2(&data->meta_hash, CURL_UNCONST(key), strlen(key) + 1, meta_data, meta_dtor)) { meta_dtor(CURL_UNCONST(key), strlen(key) + 1, meta_data); diff --git a/lib/ftp.c b/lib/ftp.c index d78a13ed82..40e08be47b 100644 --- a/lib/ftp.c +++ b/lib/ftp.c @@ -4412,7 +4412,7 @@ static CURLcode ftp_setup_connection(struct Curl_easy *data, ftp = calloc(1, sizeof(*ftp)); if(!ftp || - Curl_meta_set(data, CURL_META_FTP_EASY, ftp, ftp_easy_dtor)) + Curl_meta_set(data, CURL_META_FTP_EASY, ftp, ftp_easy_dtor)) return CURLE_OUT_OF_MEMORY; ftpc = calloc(1, sizeof(*ftpc)); diff --git a/lib/pop3.c b/lib/pop3.c index 84570fd913..62d2e26add 100644 --- a/lib/pop3.c +++ b/lib/pop3.c @@ -1534,6 +1534,7 @@ static void pop3_easy_dtor(void *key, size_t klen, void *entry) struct POP3 *pop3 = entry; (void)key; (void)klen; + DEBUGASSERT(pop3); /* Cleanup our per-request based variables */ Curl_safefree(pop3->id); Curl_safefree(pop3->custom); @@ -1545,6 +1546,7 @@ static void pop3_conn_dtor(void *key, size_t klen, void *entry) struct pop3_conn *pop3c = entry; (void)key; (void)klen; + DEBUGASSERT(pop3c); Curl_pp_disconnect(&pop3c->pp); Curl_safefree(pop3c->apoptimestamp); free(pop3c); @@ -1556,12 +1558,12 @@ static CURLcode pop3_setup_connection(struct Curl_easy *data, struct pop3_conn *pop3c; struct POP3 *pop3 = calloc(1, sizeof(*pop3)); if(!pop3 || - Curl_meta_set(data, CURL_META_POP3_EASY, pop3, pop3_easy_dtor)) + Curl_meta_set(data, CURL_META_POP3_EASY, pop3, pop3_easy_dtor)) return CURLE_OUT_OF_MEMORY; pop3c = calloc(1, sizeof(*pop3c)); if(!pop3c || - Curl_conn_meta_set(conn, CURL_META_POP3_CONN, pop3c, pop3_conn_dtor)) + Curl_conn_meta_set(conn, CURL_META_POP3_CONN, pop3c, pop3_conn_dtor)) return CURLE_OUT_OF_MEMORY; return CURLE_OK;