diff --git a/lib/northbound.c b/lib/northbound.c index 2fabae22ba..12ca3e1006 100644 --- a/lib/northbound.c +++ b/lib/northbound.c @@ -236,7 +236,8 @@ void nb_config_replace(struct nb_config *config_dst, config_dst->version = config_src->version; /* Update dnode. */ - yang_dnode_free(config_dst->dnode); + if (config_dst->dnode) + yang_dnode_free(config_dst->dnode); if (preserve_source) { config_dst->dnode = yang_dnode_dup(config_src->dnode); } else { diff --git a/lib/yang.c b/lib/yang.c index 7daef79198..73f63b18e4 100644 --- a/lib/yang.c +++ b/lib/yang.c @@ -523,6 +523,8 @@ struct lyd_node *yang_dnode_dup(const struct lyd_node *dnode) void yang_dnode_free(struct lyd_node *dnode) { + while (dnode->parent) + dnode = dnode->parent; lyd_free_withsiblings(dnode); }