aboutsummaryrefslogtreecommitdiff
path: root/lib/hash.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2004-05-10 09:17:50 +0000
committerDaniel Stenberg <daniel@haxx.se>2004-05-10 09:17:50 +0000
commit887d78a9ad3d6326fec2894b98d042c9d2e7fcde (patch)
tree35557cf44f0b0d9603e7af586b165365b0fe96de /lib/hash.c
parent00557a5475483078c8d08c496dfc08f3efdfdfc5 (diff)
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.
Diffstat (limited to 'lib/hash.c')
-rw-r--r--lib/hash.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/hash.c b/lib/hash.c
index fcc13ed28..51634e037 100644
--- a/lib/hash.c
+++ b/lib/hash.c
@@ -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 */