From: Renato Westphal Date: Mon, 24 Jul 2017 21:41:30 +0000 (-0300) Subject: lib: fix corrupted RB trees X-Git-Tag: frr-4.0-dev~492^2 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=refs%2Fpull%2F848%2Fhead;p=mirror%2Ffrr.git lib: fix corrupted RB trees 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 --- diff --git a/lib/openbsd-tree.c b/lib/openbsd-tree.c index 7e753554c9..d171e14d25 100644 --- a/lib/openbsd-tree.c +++ b/lib/openbsd-tree.c @@ -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) {