X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=libraries%2Fliblutil%2Favl.c;h=4d6d74431ba27c12b1a26b6ae895d8645dc3aefe;hb=d8eace75a7472731d78f61df01e648e8af8deee5;hp=e5a5153d08fc11ceee4b295075891c73f1b2b701;hpb=4c89b0e80c730b93caad3e68541a527e6c4f759f;p=openldap diff --git a/libraries/liblutil/avl.c b/libraries/liblutil/avl.c index e5a5153d08..4d6d74431b 100644 --- a/libraries/liblutil/avl.c +++ b/libraries/liblutil/avl.c @@ -2,7 +2,7 @@ /* $OpenLDAP$ */ /* This work is part of OpenLDAP Software . * - * Copyright 1998-2005 The OpenLDAP Foundation. + * Copyright 1998-2006 The OpenLDAP Foundation. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -230,14 +230,13 @@ avl_delete( Avlnode **root, void* data, AVL_CMP fcmp ) /* fix stack positions: old parent of p points to q */ pptr[side] = q; if ( side ) { - --side; - r = pptr[side]; - r->avl_link[pdir[side]] = q; + r = pptr[side-1]; + r->avl_link[pdir[side-1]] = q; } else { *root = q; } /* new parent of p points to p */ - if ( depth > 1 ) { + if ( depth-side > 1 ) { r = pptr[depth-1]; r->avl_link[1] = p; } else { @@ -246,7 +245,7 @@ avl_delete( Avlnode **root, void* data, AVL_CMP fcmp ) } /* now

has at most one child, get it */ - q = p->avl_link[0]; + q = p->avl_link[0] ? p->avl_link[0] : p->avl_link[1]; ber_memfree( p );