From: Howard Chu Date: Thu, 25 May 2006 05:03:56 +0000 (+0000) Subject: Fix tavl_delete for two-node trees X-Git-Tag: OPENLDAP_REL_ENG_2_4_3ALPHA~9^2~221 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=40f818daef579281bc63ccf3bfc27162b6199f73;p=openldap Fix tavl_delete for two-node trees --- diff --git a/libraries/liblutil/tavl.c b/libraries/liblutil/tavl.c index 0e7283c554..0fd2b7992a 100644 --- a/libraries/liblutil/tavl.c +++ b/libraries/liblutil/tavl.c @@ -284,6 +284,13 @@ tavl_delete( Avlnode **root, void* data, AVL_CMP fcmp ) ber_memfree( p ); + /* Update child thread */ + if ( q ) { + for ( ; q->avl_bits[nside] == AVL_CHILD && q->avl_link[nside]; + q = q->avl_link[nside] ) ; + q->avl_link[nside] = r; + } + if ( !depth ) { *root = q; return data; @@ -295,12 +302,7 @@ tavl_delete( Avlnode **root, void* data, AVL_CMP fcmp ) side = pdir[depth]; p->avl_link[side] = q; - /* Update child thread */ - if ( q ) { - for ( ; q->avl_bits[nside] == AVL_CHILD && q->avl_link[nside]; - q = q->avl_link[nside] ) ; - q->avl_link[nside] = r; - } else { + if ( !q ) { p->avl_bits[side] = AVL_THREAD; p->avl_link[side] = r; }