apr_hash.c has a very obscure bug in it, though I'm very surprised nobody
has been bitten by it before.  It is possible, when expanding the table, 
to use an old pointer and overwrite the hash entry value upon return from 
find_entry.  Anyway, this small patch fixes it.  I have a testhash.c for 
the tests directory as well, if anyone thinks we need it.

-- Jon



Index: apr_hash.c
===================================================================
RCS file: /home/cvspublic/apr/tables/apr_hash.c,v
retrieving revision 1.16
diff -u -u -r1.16 apr_hash.c
--- apr_hash.c  2001/03/07 17:57:19     1.16
+++ apr_hash.c  2001/03/09 00:32:27
@@ -275,10 +275,7 @@
     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 @@
         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 */

Reply via email to