summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2013-02-04 15:29:01 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2013-02-04 15:29:01 +0000
commita47a5577372405090c9fcde609de160091355659 (patch)
tree274ead138782406d3a954f1a723c9983810588ca
parentf3e78b4835af86686049f5d06ba01222327d25db (diff)
In rbrepair(), make sure we never try to change the color of the
sentinel node, which is the first entry, not the root.
-rw-r--r--usr.bin/sudo/redblack.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/usr.bin/sudo/redblack.c b/usr.bin/sudo/redblack.c
index 95ac095b05f..5fcdf1f7403 100644
--- a/usr.bin/sudo/redblack.c
+++ b/usr.bin/sudo/redblack.c
@@ -418,7 +418,7 @@ rbrepair(tree, node)
{
struct rbnode *sibling;
- while (node->color == black && node != rbroot(tree)) {
+ while (node->color == black && node != rbfirst(tree)) {
if (node == node->parent->left) {
sibling = node->parent->right;
if (sibling->color == red) {
@@ -441,7 +441,7 @@ rbrepair(tree, node)
node->parent->color = black;
sibling->right->color = black;
rotate_left(tree, node->parent);
- node = rbroot(tree); /* exit loop */
+ node = rbfirst(tree); /* exit loop */
}
} else { /* if (node == node->parent->right) */
sibling = node->parent->left;
@@ -465,7 +465,7 @@ rbrepair(tree, node)
node->parent->color = black;
sibling->left->color = black;
rotate_right(tree, node->parent);
- node = rbroot(tree); /* exit loop */
+ node = rbfirst(tree); /* exit loop */
}
}
}