From 145b205177ab47860a78b68329dd4b0ac0d19036 Mon Sep 17 00:00:00 2001 From: Renato Westphal Date: Mon, 24 Jul 2017 18:41:30 -0300 Subject: [PATCH] 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 --- lib/openbsd-tree.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) 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) { -- 2.39.5