Skip to content

Commit

Permalink
Final fix for previous commit
Browse files Browse the repository at this point in the history
  • Loading branch information
alandekok committed May 3, 2014
1 parent 418a464 commit 6c9481b
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/lib/rbtree.c
Expand Up @@ -337,6 +337,8 @@ static void delete_fixup(rbtree_t *tree, rbnode_t *x, rbnode_t *parent)
{

while (x != tree->root && x->colour == BLACK) {
if (!parent) _exit(1);

if (x == parent->left) {
rbnode_t *w = parent->right;
if (w->colour == RED) {
Expand Down Expand Up @@ -430,7 +432,7 @@ static void rbtree_delete_internal(rbtree_t *tree, rbnode_t *z, bool skiplock)
parent = y->parent;
if (x != NIL) x->parent = parent;

if (parent != NIL) {
if (parent) {
if (y == parent->left) {
parent->left = x;
} else {
Expand Down Expand Up @@ -472,8 +474,11 @@ static void rbtree_delete_internal(rbtree_t *tree, rbnode_t *z, bool skiplock)
} else {
if (tree->free) tree->free(y->data);

if (y->colour == BLACK)
delete_fixup(tree, x, parent);
if (y->colour == BLACK) {
if (parent) {
delete_fixup(tree, x, parent);
} /* tree->root == x, and no fixup is necessary */
}

talloc_free(y);
}
Expand Down

0 comments on commit 6c9481b

Please sign in to comment.