summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/tree.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/tree.c b/src/tree.c
index a279fd8..2e0e875 100644
--- a/src/tree.c
+++ b/src/tree.c
@@ -183,14 +183,16 @@ mq_tree_remove_allocated(MqTree *node)
{
MqTree *child;
- /* Link previous sibling or parent to children. */
+ /* Link siblings and/or parent to children (may be NULL). */
if (node->prev) {
node->prev->next = node->first_child;
} else {
node->parent->first_child = node->first_child;
- if (!node->next) {
- node->parent->last_child = node->last_child;
- }
+ }
+ if (node->next) {
+ node->next->prev = node->last_child;
+ } else {
+ node->parent->last_child = node->last_child;
}
/* Link children to siblings (may be NULL). */