session client BUGFIX memory leak
diff --git a/src/session_client.c b/src/session_client.c
index 41f9a03..ab73ad9 100644
--- a/src/session_client.c
+++ b/src/session_client.c
@@ -2006,6 +2006,8 @@
goto cleanup;
} else {
ERR(session, "Received an invalid message (%s).", ly_errmsg(LYD_CTX(op)));
+ lyd_free_tree(*envp);
+ *envp = NULL;
ret = NC_MSG_ERROR;
goto cleanup;
}
@@ -2045,6 +2047,7 @@
lyrc = lyd_parse_op(session->ctx, NULL, in, LYD_XML, LYD_TYPE_RPC_YANG, &tree, &op2);
ly_in_free(in, 0);
if (lyrc) {
+ lyd_free_tree(tree);
return -1;
}
@@ -2240,6 +2243,8 @@
goto cleanup;
} else {
ERR(session, "Received an invalid message (%s).", ly_errmsg(session->ctx));
+ lyd_free_tree(*envp);
+ *envp = NULL;
ret = NC_MSG_ERROR;
goto cleanup;
}