tree data BUGFIX proper error handling
diff --git a/src/tree_data.c b/src/tree_data.c
index fff9f3d..ce3b13b 100644
--- a/src/tree_data.c
+++ b/src/tree_data.c
@@ -3601,7 +3601,13 @@
if (trg_ctx == LYD_CTX(node)) {
dup->schema = node->schema;
} else {
- LY_CHECK_GOTO(ret = lyd_dup_find_schema(node->schema, trg_ctx, parent, &dup->schema), error);
+ ret = lyd_dup_find_schema(node->schema, trg_ctx, parent, &dup->schema);
+ if (ret) {
+ /* has no schema but is not an opaque node */
+ free(dup);
+ dup = NULL;
+ goto error;
+ }
}
dup->prev = dup;