diff options
author | Daniel Stenberg <daniel@haxx.se> | 2021-12-08 13:22:44 +0100 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2021-12-08 13:22:44 +0100 |
commit | 915461f59c8fece754a302d67f6970ee3922c54f (patch) | |
tree | fbb8d6a99c9c70d820b5cb11b4890fa30972f408 | |
parent | e28628ffc22f3516a6560fbd6d8a19c50fa74306 (diff) | |
download | curl-bagder/detected-bad-hash.tar.gz |
hash: add asserts to help detect bad usagebagder/detected-bad-hash
-rw-r--r-- | lib/hash.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/hash.c b/lib/hash.c index 12e7aa5f2..f04c46284 100644 --- a/lib/hash.c +++ b/lib/hash.c @@ -110,7 +110,9 @@ Curl_hash_add(struct Curl_hash *h, void *key, size_t key_len, void *p) { struct Curl_hash_element *he; struct Curl_llist_element *le; - struct Curl_llist *l = FETCH_LIST(h, key, key_len); + struct Curl_llist *l; + DEBUGASSERT(h->slots); + l = FETCH_LIST(h, key, key_len); for(le = l->head; le; le = le->next) { he = (struct Curl_hash_element *) le->ptr; @@ -139,7 +141,9 @@ Curl_hash_add(struct Curl_hash *h, void *key, size_t key_len, void *p) int Curl_hash_delete(struct Curl_hash *h, void *key, size_t key_len) { struct Curl_llist_element *le; - struct Curl_llist *l = FETCH_LIST(h, key, key_len); + struct Curl_llist *l; + DEBUGASSERT(h->slots); + l = FETCH_LIST(h, key, key_len); for(le = l->head; le; le = le->next) { struct Curl_hash_element *he = le->ptr; @@ -163,6 +167,7 @@ Curl_hash_pick(struct Curl_hash *h, void *key, size_t key_len) struct Curl_llist *l; if(h) { + DEBUGASSERT(h->slots); l = FETCH_LIST(h, key, key_len); for(le = l->head; le; le = le->next) { struct Curl_hash_element *he = le->ptr; |