Fix memory leaks in maxinfo (modified for 2.0 and develop-branch)

MXS-1009. This commit adds a gwbuf_free after maxinfo_execute() to
free a buffer with an sql-query after it has been processed. Also,
the parse tree in maxinfo_execute_query() is now freed. The tree_free-
function was renamed to maxinfo_tree_free, since it is now globally
available.

This commit has additional changes (in relation to the 1.4.4 branch)
to remove errors caused by differences in the html and sql-sides of
MaxInfo.
This commit is contained in:
ekorh475
2016-11-25 12:53:15 +02:00
parent 0bc68742a6
commit cc54d80a8b
4 changed files with 186 additions and 156 deletions

View File

@ -881,22 +881,28 @@ variable_row(RESULTSET *result, void *data)
static void
exec_show_variables(DCB *dcb, MAXINFO_TREE *filter)
{
RESULTSET *result;
VARCONTEXT context;
RESULTSET *result;
VARCONTEXT *context;
if ((context = malloc(sizeof(VARCONTEXT))) == NULL)
{
return;
}
if (filter)
{
context.like = filter->value;
context->like = filter->value;
}
else
{
context.like = NULL;
context->like = NULL;
}
context.index = 0;
context->index = 0;
if ((result = resultset_create(variable_row, &context)) == NULL)
if ((result = resultset_create(variable_row, context)) == NULL)
{
maxinfo_send_error(dcb, 0, "No resources available");
free(context);
return;
}
resultset_add_column(result, "Variable_name", 40, COL_TYPE_VARCHAR);
@ -1167,22 +1173,28 @@ status_row(RESULTSET *result, void *data)
static void
exec_show_status(DCB *dcb, MAXINFO_TREE *filter)
{
RESULTSET *result;
VARCONTEXT context;
RESULTSET *result;
VARCONTEXT *context;
if ((context = malloc(sizeof(VARCONTEXT))) == NULL)
{
return;
}
if (filter)
{
context.like = filter->value;
context->like = filter->value;
}
else
{
context.like = NULL;
context->like = NULL;
}
context.index = 0;
context->index = 0;
if ((result = resultset_create(status_row, &context)) == NULL)
if ((result = resultset_create(status_row, context)) == NULL)
{
maxinfo_send_error(dcb, 0, "No resources available");
free(context);
return;
}
resultset_add_column(result, "Variable_name", 40, COL_TYPE_VARCHAR);