Skip to content

Commit

Permalink
util/RedBlackTree: swap colors when swapping with successor
Browse files Browse the repository at this point in the history
Swapping was incomplete without swapping the colors; this led to
assertion failures under certain conditions.
  • Loading branch information
MaxKellermann committed Apr 10, 2024
1 parent 460ddf8 commit 615640f
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/util/RedBlackTree.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,8 @@ public:
auto &p = *parent;
const auto direction_in_parent = p.GetChildDirection(*this);

std::swap(color, successor.color);

successor.SetChild(Direction::LEFT, GetLeft());
SetChild(Direction::LEFT, nullptr);
SetChild(Direction::RIGHT, successor.GetRight());
Expand Down

0 comments on commit 615640f

Please sign in to comment.