From 04d97d1a3a811a2e7eec75da093afdbc4045956c Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Fri, 6 Sep 2013 23:21:44 +0000 Subject: [PATCH] btr: splice-out fix. When splicing out a node we set the ->parent pointer of all child nodes to the parent of the given node, and move each child to the ->children list of the parent. Except when there is no parent. If the given node was a root node (or an internal node whose parent vanished), we leave the ->children list untouched. In this case the assertion a few lines later triggers and aborts the program. Fix this by removing the nodes from the list. Such nodes have become root nodes themselves, so they should not be on any list of children. --- buffer_tree.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/buffer_tree.c b/buffer_tree.c index fd0a59ca..aa9f1cdb 100644 --- a/buffer_tree.c +++ b/buffer_tree.c @@ -856,6 +856,8 @@ void btr_splice_out_node(struct btr_node *btrn) ch->parent = btrn->parent; if (btrn->parent) list_move(&ch->node, &btrn->parent->children); + else + list_del(&ch->node); } assert(list_empty(&btrn->children)); btrn->parent = NULL; -- 2.39.5