Skip to content

Commit

Permalink
lib: fix corrupted RB trees
Browse files Browse the repository at this point in the history
Commit 8f942af introduced a bug while silencing a clang warning. Silence
the warning in a different way to fix our red-black tree implementation.

Fixes FRRouting#841.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
  • Loading branch information
rwestphal committed Jul 24, 2017
1 parent 52535be commit 145b205
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions lib/openbsd-tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 145b205

Please sign in to comment.