From: Todd C. Miller Date: Tue, 1 Jan 2013 21:24:29 +0000 (-0500) Subject: In rbrepair(), make sure we never try to change the color of the X-Git-Tag: SUDO_1_7_10p4~7 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2272be2dc9bdc4ca778f2c0e9b86067bff959fc9;p=sudo In rbrepair(), make sure we never try to change the color of the sentinel node, which is the first entry, not the root. From Michael King --HG-- branch : 1.7 --- diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 275446192..d63a74467 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -71,6 +71,7 @@ you believe you should be listed, please send a note to sudo@sudo.ws. Stepan Kasal Mike Kienenberger Dale King + Michael King Jim Knoble Tim Knox Alek O. Komarnitsky @@ -116,7 +117,7 @@ you believe you should be listed, please send a note to sudo@sudo.ws. Diego Elio Petteno Joel Pickett Alex Plotnick - Tran Ngoc Quan + Tran Ngoc Quan Gudleik Rasch Matt Richards Guido van Rossum diff --git a/redblack.c b/redblack.c index fb3611b2d..04adae64f 100644 --- a/redblack.c +++ b/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 */ } } }