Skip to content

Commit 86defdc

Browse files
committed
diff BUGFIX different context diff
1 parent b7f865d commit 86defdc

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/diff.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,12 @@ lyd_diff_add(const struct lyd_node *node, enum lyd_diff_op op, const char *orig_
413413
}
414414

415415
/* duplicate the subtree (and connect to the diff if possible) */
416-
LY_CHECK_RET(lyd_dup_single(node, (struct lyd_node_inner *)diff_parent, diff_opts, &dup));
416+
if (diff_parent && (LYD_CTX(diff_parent) != LYD_CTX(node))) {
417+
LY_CHECK_RET(lyd_dup_single_to_ctx(node, LYD_CTX(diff_parent), (struct lyd_node_inner *)diff_parent,
418+
diff_opts, &dup));
419+
} else {
420+
LY_CHECK_RET(lyd_dup_single(node, (struct lyd_node_inner *)diff_parent, diff_opts, &dup));
421+
}
417422

418423
/* find the first duplicated parent */
419424
if (!diff_parent) {

0 commit comments

Comments
 (0)