Skip to content
Snippets Groups Projects
Commit 887d78a9 authored by Daniel Stenberg's avatar Daniel Stenberg
Browse files

Curl_hash_add() was modified to clear up better in case of internal failure.

When failing, it should not tamper at all with the data it was supposed to
add to the cache.
parent 00557a54
No related branches found
No related tags found
No related merge requests found
......@@ -169,8 +169,14 @@ Curl_hash_add(curl_hash *h, char *key, size_t key_len, void *p)
++h->size;
return p; /* return the new entry */
}
/* couldn't insert it, destroy the 'he' element again */
hash_element_dtor(h, he);
/*
* Couldn't insert it, destroy the 'he' element and the key again. We
* don't call hash_element_dtor() since that would also call the
* "destructor" for the actual data 'p'. When we fail, we shall not touch
* that data.
*/
free(he->key);
free(he);
}
return NULL; /* failure */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment