]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
hash: add asserts in hash_element_dtor()
authorDaniel Stenberg <daniel@haxx.se>
Wed, 1 Jan 2025 19:37:47 +0000 (20:37 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Wed, 1 Jan 2025 20:13:38 +0000 (21:13 +0100)
This just adds a precaution and shows a clear intention in the code.
Added because CodeSonar is reporting a false positive Use After Free on
this function.

Closes #15889

lib/hash.c

index 1910ac5dc49fbbce7b3996ef39b6816112f847ce..aa9904e7099e9aa67a9be515fa293ef48676bce2 100644 (file)
@@ -42,6 +42,8 @@ hash_element_dtor(void *user, void *element)
 {
   struct Curl_hash *h = (struct Curl_hash *) user;
   struct Curl_hash_element *e = (struct Curl_hash_element *) element;
+  DEBUGASSERT(h);
+  DEBUGASSERT(e);
 
   if(e->ptr) {
     if(e->dtor)