schema tree BUGFIX unlinking augment data
In case the module is not implemented or it was disabled, the augment
data are actually not connected with the augment target, so when
unlinking (freeing) such a data, we cannot check access the target node
since it can be already freed.
Fixes #236
diff --git a/src/tree_schema.c b/src/tree_schema.c
index a7f866c..a9541f2 100644
--- a/src/tree_schema.c
+++ b/src/tree_schema.c
@@ -345,8 +345,14 @@
if (parent->child == node) {
parent->child = node->next;
}
- /* and then continue with the target parent */
- parent = ((struct lys_node_augment *)parent)->target;
+
+ if (parent->flags & LYS_NOTAPPLIED) {
+ /* data are not connected in the target, so we cannot continue with the target as a parent */
+ parent = NULL;
+ } else {
+ /* data are connected in target, so we will continue with the target as a parent */
+ parent = ((struct lys_node_augment *)parent)->target;
+ }
}
/* unlink from parent */