From 88475f2e2be3e59ac7800783af6dde85a4f19dd4 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 10 Apr 2024 12:15:22 +0200 Subject: [PATCH] util/RedBlackTree: swap colors when swapping with successor Swapping was incomplete without swapping the colors; this led to assertion failures under certain conditions. --- src/util/RedBlackTree.hxx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/util/RedBlackTree.hxx b/src/util/RedBlackTree.hxx index 07012cede..2cffb156f 100644 --- a/src/util/RedBlackTree.hxx +++ b/src/util/RedBlackTree.hxx @@ -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());