]> git.puffer.fish Git - mirror/frr.git/commitdiff
lib: fix corrupted RB trees 848/head
authorRenato Westphal <renato@opensourcerouting.org>
Mon, 24 Jul 2017 21:41:30 +0000 (18:41 -0300)
committerRenato Westphal <renato@opensourcerouting.org>
Mon, 24 Jul 2017 21:50:45 +0000 (18:50 -0300)
Commit 8f942af90 introduced a bug while silencing a clang warning. Silence
the warning in a different way to fix our red-black tree implementation.

Fixes #841.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
lib/openbsd-tree.c

index 7e753554c93e2695a83b14076aeeb5e79d205f0f..d171e14d25dc0b22366f1166ae47fb7f107ff3f4 100644 (file)
@@ -222,12 +222,8 @@ rbe_remove_color(const struct rb_type *t, struct rbt_tree *rbt,
 {
        struct rb_entry *tmp;
 
-       /* Silence clang possible NULL deference warning. */
-       if (parent == NULL)
-               return;
-
        while ((rbe == NULL || RBE_COLOR(rbe) == RB_BLACK) &&
-           rbe != RBH_ROOT(rbt)) {
+           rbe != RBH_ROOT(rbt) && parent) {
                if (RBE_LEFT(parent) == rbe) {
                        tmp = RBE_RIGHT(parent);
                        if (RBE_COLOR(tmp) == RB_RED) {