Return-Path: Delivered-To: apmail-httpd-apreq-cvs-archive@httpd.apache.org Received: (qmail 94069 invoked by uid 500); 29 Apr 2003 07:34:05 -0000 Mailing-List: contact apreq-cvs-help@httpd.apache.org; run by ezmlm Precedence: bulk Reply-To: apreq-dev@httpd.apache.org List-Post: List-Help: List-Unsubscribe: List-Subscribe: Delivered-To: mailing list apreq-cvs@httpd.apache.org Received: (qmail 94056 invoked by uid 500); 29 Apr 2003 07:34:05 -0000 Delivered-To: apmail-httpd-apreq-2-cvs@apache.org Received: (qmail 94053 invoked from network); 29 Apr 2003 07:34:05 -0000 Received: from icarus.apache.org (208.185.179.13) by daedalus.apache.org with SMTP; 29 Apr 2003 07:34:05 -0000 Received: (qmail 44675 invoked by uid 1221); 29 Apr 2003 07:34:04 -0000 Date: 29 Apr 2003 07:34:04 -0000 Message-ID: <20030429073404.44674.qmail@icarus.apache.org> From: joes@apache.org To: httpd-apreq-2-cvs@apache.org Subject: cvs commit: httpd-apreq-2/src apreq_tables.c X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N joes 2003/04/29 00:34:04 Modified: src apreq_tables.c Log: Fix segfaults in balanced-tree deletes (x == -1 case). Revision Changes Path 1.26 +13 -7 httpd-apreq-2/src/apreq_tables.c Index: apreq_tables.c =================================================================== RCS file: /home/cvs/httpd-apreq-2/src/apreq_tables.c,v retrieving revision 1.25 retrieving revision 1.26 diff -u -r1.25 -r1.26 --- apreq_tables.c 29 Apr 2003 03:41:17 -0000 1.25 +++ apreq_tables.c 29 Apr 2003 07:34:04 -0000 1.26 @@ -153,12 +153,12 @@ #define KILL(t,idx) do { (idx)[o].key = NULL; \ (t)->ghosts++; } while (0) #define RESURRECT(t,idx) do { (idx)[o].key = (idx)[o].val->name; \ - COMPUTE_KEY_CHECKSUM((idx[o].key),(idx)[o].checksum); \ + COMPUTE_KEY_CHECKSUM((idx)[o].key,(idx)[o].checksum); \ (t)->ghosts--; } while (0) /* NEVER KILL AN ENTRY THAT'S STILL WITHIN THE FOREST */ #define IN_FOREST(t,idx) ( !DEAD(idx) && ( (idx)[o].tree[UP] >= 0 || \ - (idx) == t->root[TABLE_HASH((idx)[o].checksum>>24)] ) ) + (idx) == t->root[TABLE_HASH((idx)[o].checksum>>24)] ) ) /* MUST ensure n's parent exists (>=0) before using LR(n) */ #define LR(n) ( ( (n)[o].tree[UP][o].tree[LEFT] == (n) ) ? LEFT : RIGHT ) @@ -369,6 +369,8 @@ if (x >= 0) x[o].tree[UP] = parent; + else + x = parent; if (flags & TF_BALANCE == 0 || idx[o].color == RED) return; @@ -389,7 +391,12 @@ x[o].tree[UP] = y[o].tree[UP]; y[o].tree[UP][o].tree[LR(y)] = x; } + else + x = y[o].tree[UP]; } + else + if (x < 0) + x = parent; /* copy idx's tree data into y ("RIGHT" is already done). */ y[o].tree[LEFT] = idx[o].tree[LEFT]; @@ -405,10 +412,8 @@ y[o].color = idx[o].color; return; } - else { + else y[o].color = idx[o].color; - x = y; - } } @@ -420,7 +425,7 @@ * */ - while (x[o].color == BLACK && x != *root) { + while (x != *root && x[o].color == BLACK) { /* x has a parent & sibling */ int parent = x[o].tree[UP]; register const int direction = LR(x); @@ -686,7 +691,8 @@ for (idx = 0; idx < t->a.nelts; ++idx) if (!DEAD(idx)) insert(o, &t->root[TABLE_HASH(idx[o].checksum>>24)], - t->root[TABLE_HASH(idx[o].checksum>>24)], idx+o, TF_BALANCE); + t->root[TABLE_HASH(idx[o].checksum>>24)], idx+o, + TF_BALANCE); t->flags |= TF_BALANCE; }