data tree BUGFIX create default nodes in existing cases
diff --git a/src/tree_data.c b/src/tree_data.c
index f3c3b87..19633a7 100644
--- a/src/tree_data.c
+++ b/src/tree_data.c
@@ -1445,10 +1445,16 @@
switch (iter->nodetype) {
case LYS_CHOICE:
- if (((struct lysc_node_choice *)iter)->dflt && !lys_getnext_data(NULL, *first, NULL, iter, NULL)) {
+ node = lys_getnext_data(NULL, *first, NULL, iter, NULL);
+ if (!node && ((struct lysc_node_choice *)iter)->dflt) {
/* create default case data */
LY_CHECK_RET(lyd_new_implicit_r(parent, first, (struct lysc_node *)((struct lysc_node_choice *)iter)->dflt,
NULL, node_types, node_when, impl_opts, diff));
+ } else if (node) {
+ /* create any default data in the existing case */
+ assert(node->schema->parent->nodetype == LYS_CASE);
+ LY_CHECK_RET(lyd_new_implicit_r(parent, first, node->schema->parent, NULL, node_types, node_when,
+ impl_opts, diff));
}
break;
case LYS_CONTAINER: