diff --git a/src/rbtree.cpp b/src/rbtree.cpp index f01e31db51de94..a22133e54f23ab 100644 --- a/src/rbtree.cpp +++ b/src/rbtree.cpp @@ -70,10 +70,10 @@ class Tree template void fix_insert(Node* z) { - while (z != m_roots[I] && !z->m_positions[I].m_black) { + while (z != m_roots[I] && !z->m_positions[I].m_parent->m_positions[I].m_black) { if (z->m_positions[I].m_parent == z->m_positions[I].m_parent->m_positions[I].m_parent->m_positions[I].m_left) { Node* y = z->m_positions[I].m_parent->m_positions[I].m_parent->m_positions[I].m_right; - if (y != nullptr && !z->m_positions[I].m_black) { + if (y != nullptr && !y->m_positions[I].m_black) { z->m_positions[I].m_parent->m_positions[I].m_black = true; y->m_positions[I].m_black = true; z->m_positions[I].m_parent->m_positions[I].m_parent->m_positions[I].m_black = false;