From dev-return-1649-apmail-apr-dev-archive=apr.apache.org@apr.apache.org Sat Mar 10 00:13:20 2001 Return-Path: Delivered-To: apmail-apr-dev-archive@apr.apache.org Received: (qmail 36131 invoked by uid 500); 10 Mar 2001 00:08:47 -0000 Mailing-List: contact dev-help@apr.apache.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Delivered-To: mailing list dev@apr.apache.org Received: (qmail 35138 invoked from network); 10 Mar 2001 00:07:48 -0000 Date: Fri, 9 Mar 2001 16:07:38 -0800 (PST) From: X-Sender: To: Jon Travis Cc: Subject: Re: [PATCH: apr_hash.c] In-Reply-To: <20010308163943.A5471@covalent.net> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Spam-Rating: h31.sny.collab.net 1.6.2 0/1000/N Committed, thanks. Ryan On Thu, 8 Mar 2001, Jon Travis wrote: > 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 */ > > _______________________________________________________________________________ Ryan Bloom rbb@apache.org 406 29th St. San Francisco, CA 94131 -------------------------------------------------------------------------------