lib: fix yang_dnode_dup

When duplicating nodes, we should always keep flags, especially the
LYD_NEW flag that indicates not validated data. This allows to select a
new choice's case without the need to explicitly remove the existing one.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
This commit is contained in:
Igor Ryzhov 2024-01-24 22:26:47 +02:00
parent 741d1d0090
commit fe76036002

View file

@ -628,7 +628,8 @@ struct lyd_node *yang_dnode_dup(const struct lyd_node *dnode)
{
struct lyd_node *dup = NULL;
LY_ERR err;
err = lyd_dup_siblings(dnode, NULL, LYD_DUP_RECURSIVE, &dup);
err = lyd_dup_siblings(dnode, NULL,
LYD_DUP_RECURSIVE | LYD_DUP_WITH_FLAGS, &dup);
assert(!err);
return dup;
}