diff options
author | rbb <rbb@13f79535-47bb-0310-9956-ffa450edef68> | 2001-03-10 00:07:09 +0000 |
---|---|---|
committer | rbb <rbb@13f79535-47bb-0310-9956-ffa450edef68> | 2001-03-10 00:07:09 +0000 |
commit | 490999ae63bbf1e2cb72a2d14eacb6bd9c4867bc (patch) | |
tree | c462c540e405fcae403a811aeae57d0d75905a12 | |
parent | 8081a187ac7fa694ddfa67b0556a574269dea22c (diff) | |
download | libapr-490999ae63bbf1e2cb72a2d14eacb6bd9c4867bc.tar.gz |
Fix a subtle bug in the hash tables. We can't expand the array after
finding the entry because if we do, we immediately overwrite the value.
Intead, we have to expand the hash after setting the value.
Submitted by: Jon Travis <jtravis@covalent.net>
Reviewed by: Ryan Bloom
git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@61356 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | tables/apr_hash.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/tables/apr_hash.c b/tables/apr_hash.c index 7e7a59ba4..8085ee33f 100644 --- a/tables/apr_hash.c +++ b/tables/apr_hash.c @@ -275,10 +275,7 @@ static apr_hash_entry_t **find_entry(apr_hash_t *ht, he->klen = klen; he->val = val; *hep = he; - /* check that the collision rate isn't too high */ - if (++ht->count > ht->max) { - expand_array(ht); - } + ht->count++; return hep; } @@ -310,6 +307,10 @@ APR_DECLARE(void) apr_hash_set(apr_hash_t *ht, else { /* replace entry */ (*hep)->val = val; + /* check that the collision rate isn't too high */ + if (ht->count > ht->max) { + expand_array(ht); + } } } /* else key not present and val==NULL */ |