From fe76036002c65428c189849b578d30a3a4c179a2 Mon Sep 17 00:00:00 2001 From: Igor Ryzhov Date: Wed, 24 Jan 2024 22:26:47 +0200 Subject: [PATCH] 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 --- lib/yang.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/yang.c b/lib/yang.c index 7a3d6df497..3dd2513a4b 100644 --- a/lib/yang.c +++ b/lib/yang.c @@ -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; }