data tree BUGFIX inserting opaque nodes
diff --git a/src/tree_data.c b/src/tree_data.c
index fdc9a1e..1db88a3 100644
--- a/src/tree_data.c
+++ b/src/tree_data.c
@@ -1950,9 +1950,13 @@
{
const struct lysc_node *par2;
- assert(schema);
assert(!parent || !(parent->nodetype & (LYS_CASE | LYS_CHOICE)));
+ if (!parent || !schema) {
+ /* opaque nodes can be inserted wherever */
+ return LY_SUCCESS;
+ }
+
/* find schema parent */
par2 = lysc_data_parent(schema);
@@ -2017,7 +2021,7 @@
}
while (node) {
- if (node->schema->flags & LYS_KEY) {
+ if (lysc_is_key(node->schema)) {
LOGERR(LYD_CTX(node), LY_EINVAL, "Cannot insert key \"%s\".", node->schema->name);
return LY_EINVAL;
}