tree data BUGFIX meta values always use annotation context
diff --git a/src/tree_data.c b/src/tree_data.c
index 043fbd0..66ef8a3 100644
--- a/src/tree_data.c
+++ b/src/tree_data.c
@@ -1882,17 +1882,21 @@
lyd_dup_meta_single(const struct lyd_meta *meta, struct lyd_node *node, struct lyd_meta **dup)
{
LY_ERR ret = LY_SUCCESS;
+ const struct ly_ctx *ctx;
struct lyd_meta *mt, *last;
LY_CHECK_ARG_RET(NULL, meta, node, LY_EINVAL);
+ /* log to node context but value must always use the annotation context */
+ ctx = meta->annotation->module->ctx;
+
/* create a copy */
mt = calloc(1, sizeof *mt);
LY_CHECK_ERR_RET(!mt, LOGMEM(LYD_CTX(node)), LY_EMEM);
mt->annotation = meta->annotation;
- ret = meta->value.realtype->plugin->duplicate(LYD_CTX(node), &meta->value, &mt->value);
+ ret = meta->value.realtype->plugin->duplicate(ctx, &meta->value, &mt->value);
LY_CHECK_ERR_GOTO(ret, LOGERR(LYD_CTX(node), LY_EINT, "Value duplication failed."), finish);
- LY_CHECK_GOTO(ret = lydict_insert(LYD_CTX(node), meta->name, 0, &mt->name), finish);
+ LY_CHECK_GOTO(ret = lydict_insert(ctx, meta->name, 0, &mt->name), finish);
/* insert as the last attribute */
mt->parent = node;
diff --git a/src/tree_data_new.c b/src/tree_data_new.c
index 148562f..1e4875a 100644
--- a/src/tree_data_new.c
+++ b/src/tree_data_new.c
@@ -749,7 +749,7 @@
LY_CHECK_ARG_RET(ctx, ctx || parent, name, module || strchr(name, ':'), parent || meta, LY_EINVAL);
LY_CHECK_CTX_EQUAL_RET(ctx, parent ? LYD_CTX(parent) : NULL, module ? module->ctx : NULL, LY_EINVAL);
if (!ctx) {
- ctx = LYD_CTX(parent);
+ ctx = module ? module->ctx : LYD_CTX(parent);
}
if (parent && !parent->schema) {