Skip to content

Commit a95aff3

Browse files
committed
data tree BUGFIX do not free linked nodes
Fixes #697
1 parent 3ab8b45 commit a95aff3

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/tree_data.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2811,17 +2811,19 @@ lyd_merge_parent_children(struct lyd_node *target, struct lyd_node *source, int
28112811
src_elem_backup = lyd_dup_to_ctx(src_elem_backup, 1, ctx);
28122812
}
28132813

2814+
if (src_elem == source) {
2815+
/* it will be linked into another data tree and the pointers changed */
2816+
source = source->next;
2817+
}
2818+
28142819
/* insert subtree into the target */
28152820
if (lyd_insert(trg_parent_backup, src_elem_backup)) {
28162821
LOGINT(ctx);
28172822
lyd_free_withsiblings(source);
28182823
return 1;
28192824
}
28202825
if (src_elem == src) {
2821-
/* we are finished for this src, we spent it, so forget the pointer if available */
2822-
if (source == src) {
2823-
source = source->next;
2824-
}
2826+
/* we are finished for this src */
28252827
break;
28262828
}
28272829
}

0 commit comments

Comments
 (0)