libyang BUGFIX memory leaks
diff --git a/src/parser_lyb.c b/src/parser_lyb.c
index 3c8fa76..3cd222e 100644
--- a/src/parser_lyb.c
+++ b/src/parser_lyb.c
@@ -999,7 +999,7 @@
lybctx = calloc(1, sizeof *lybctx);
LY_CHECK_ERR_RET(!lybctx, LOGMEM(ctx), LY_EMEM);
lybctx->lybctx = calloc(1, sizeof *lybctx->lybctx);
- LY_CHECK_ERR_RET(!lybctx->lybctx, LOGMEM(ctx), LY_EMEM);
+ LY_CHECK_ERR_GOTO(!lybctx->lybctx, LOGMEM(ctx); ret = LY_EMEM, cleanup);
lybctx->lybctx->in = in;
lybctx->lybctx->ctx = ctx;
diff --git a/src/printer_lyb.c b/src/printer_lyb.c
index e2d60bd..bbec259 100644
--- a/src/printer_lyb.c
+++ b/src/printer_lyb.c
@@ -1005,7 +1005,8 @@
if (root->schema && lysc_data_parent(root->schema)) {
LOGERR(lybctx->lybctx->ctx, LY_EINVAL, "LYB printer supports only printing top-level nodes.");
- return LY_EINVAL;
+ ret = LY_EINVAL;
+ goto cleanup;
}
}
diff --git a/src/tree_schema_compile.c b/src/tree_schema_compile.c
index d454a2a..521c59a 100644
--- a/src/tree_schema_compile.c
+++ b/src/tree_schema_compile.c
@@ -6033,12 +6033,12 @@
/* check that the values matches */
dflt = leaf->dflt->realtype->plugin->print(leaf->dflt, LYD_XML, lys_get_prefix, leaf->dflt_mod, &i);
if (strcmp(dflt, d->dflts[0])) {
- if (i) {
- free((char*)dflt);
- }
LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_REFERENCE,
"Invalid deviation deleting \"default\" property \"%s\" which does not match the target's property value \"%s\".",
d->dflts[0], dflt);
+ if (i) {
+ free((char*)dflt);
+ }
goto cleanup;
}
if (i) {