data validation BUGFIX checking top level mandatory elements
In case of top-level choice, wrong data were searched for mandatory
element instance.
diff --git a/src/tree_schema.c b/src/tree_schema.c
index 79d58b0..5024e32 100644
--- a/src/tree_schema.c
+++ b/src/tree_schema.c
@@ -448,7 +448,7 @@
ly_check_mandatory(const struct lyd_node *data, const struct lys_node *schema, int status, int rpc_output)
{
const struct lys_node *siter, *saux, *saux2, *parent = NULL, *parent2;
- const struct lyd_node *diter;
+ const struct lyd_node *diter, *datasearch;
int found;
assert(data || schema);
@@ -456,10 +456,12 @@
if (schema) {
/* schema is preferred regardless the data */
siter = schema;
+ datasearch = data;
} else {
/* !schema && data */
schema = data->schema;
siter = data->schema->child;
+ datasearch = data->child;
}
repeat:
@@ -509,7 +511,7 @@
case LYS_LEAFLIST:
case LYS_LIST:
case LYS_ANYXML:
- LY_TREE_FOR(data->child, diter) {
+ LY_TREE_FOR(datasearch, diter) {
if (diter->schema == siter) {
break;
}