hash: add asserts in hash_element_dtor()

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
This commit is contained in:
Daniel Stenberg 2025-01-01 20:37:47 +01:00
parent 7fed7274e4
commit 7fb113f01f
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2

View 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)