]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
btr: splice-out fix.
authorAndre Noll <maan@systemlinux.org>
Fri, 6 Sep 2013 23:21:44 +0000 (23:21 +0000)
committerAndre Noll <maan@systemlinux.org>
Sun, 22 Sep 2013 00:10:27 +0000 (02:10 +0200)
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

index fd0a59cad58c0027e3911b08eb5f0bd20a176ed5..aa9f1cdb0c95b77635981cea0e6bb1588bbcdc03 100644 (file)
@@ -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;