libyang BUGFIX NULL-pointer dereference
reported by coverity
diff --git a/src/parser_lyb.c b/src/parser_lyb.c
index d9366f8..b2aca77 100644
--- a/src/parser_lyb.c
+++ b/src/parser_lyb.c
@@ -223,6 +223,7 @@
LY_ARRAY_SIZE_TYPE u;
if (!lybctx->subtrees) {
+ assert(lybctx->subtree_size == 0);
u = 0;
} else {
u = LY_ARRAY_SIZE(lybctx->subtrees);
diff --git a/src/printer_lyb.c b/src/printer_lyb.c
index dc03f61..ba2ad27 100644
--- a/src/printer_lyb.c
+++ b/src/printer_lyb.c
@@ -342,6 +342,7 @@
LY_ARRAY_SIZE_TYPE u;
if (!lybctx->subtrees) {
+ assert(lybctx->subtree_size == 0);
u = 0;
} else {
u = LY_ARRAY_SIZE(lybctx->subtrees);
diff --git a/src/tree_data.c b/src/tree_data.c
index b558038..7fb5d58 100644
--- a/src/tree_data.c
+++ b/src/tree_data.c
@@ -1467,13 +1467,13 @@
if (parent) {
/* inner node */
if (par2 != parent) {
- LOGERR(parent->module->ctx, LY_EINVAL, "Cannot insert, parent of \"%s\" is not \"%s\".", schema->name, parent->name);
+ LOGERR(schema->module->ctx, LY_EINVAL, "Cannot insert, parent of \"%s\" is not \"%s\".", schema->name, parent->name);
return LY_EINVAL;
}
} else {
/* top-level node */
if (par2) {
- LOGERR(parent->module->ctx, LY_EINVAL, "Cannot insert, node \"%s\" is not top-level.", schema->name);
+ LOGERR(schema->module->ctx, LY_EINVAL, "Cannot insert, node \"%s\" is not top-level.", schema->name);
return LY_EINVAL;
}
}