lyb parser BUGFIX return value fixed
Even if the parser context is not returned,
the function should succeed if ret is 0.
diff --git a/src/parser_lyb.c b/src/parser_lyb.c
index 056d70c..30878c5 100644
--- a/src/parser_lyb.c
+++ b/src/parser_lyb.c
@@ -1091,13 +1091,15 @@
}
cleanup:
- if (ret || !lydctx_p) {
+ if (ret) {
lyd_lyb_ctx_free((struct lyd_ctx *)lybctx);
- if (ret) {
- lyd_free_all(tree);
- }
+ lyd_free_all(tree);
} else {
- *lydctx_p = (struct lyd_ctx *)lybctx;
+ if (lydctx_p) {
+ *lydctx_p = (struct lyd_ctx *)lybctx;
+ } else {
+ lyd_lyb_ctx_free((struct lyd_ctx *)lybctx);
+ }
if (tree_p) {
*tree_p = tree;
}