MXS-1220: Fix memory leaks
Some of the JSON objects created in the diagnostic functions leaked memory.
This commit is contained in:

committed by
Markus Mäkelä

parent
ebc9e4bd3b
commit
bc3cfe0221
@ -363,22 +363,22 @@ static json_t* diagnostic(MXS_FILTER *instance, MXS_FILTER_SESSION *fsession)
|
||||
CCR_INSTANCE *my_instance = (CCR_INSTANCE *)instance;
|
||||
json_t* rval = json_object();
|
||||
|
||||
json_object_set(rval, "count", json_integer(my_instance->count));
|
||||
json_object_set(rval, "time", json_integer(my_instance->time));
|
||||
json_object_set_new(rval, "count", json_integer(my_instance->count));
|
||||
json_object_set_new(rval, "time", json_integer(my_instance->time));
|
||||
|
||||
if (my_instance->match)
|
||||
{
|
||||
json_object_set(rval, "match", json_string(my_instance->match));
|
||||
json_object_set_new(rval, "match", json_string(my_instance->match));
|
||||
}
|
||||
|
||||
if (my_instance->nomatch)
|
||||
{
|
||||
json_object_set(rval, "nomatch", json_string(my_instance->nomatch));
|
||||
json_object_set_new(rval, "nomatch", json_string(my_instance->nomatch));
|
||||
}
|
||||
|
||||
json_object_set(rval, "data_modifications", json_integer(my_instance->stats.n_modified));
|
||||
json_object_set(rval, "hints_added_count", json_integer(my_instance->stats.n_add_count));
|
||||
json_object_set(rval, "hints_added_time", json_integer(my_instance->stats.n_add_time));
|
||||
json_object_set_new(rval, "data_modifications", json_integer(my_instance->stats.n_modified));
|
||||
json_object_set_new(rval, "hints_added_count", json_integer(my_instance->stats.n_add_count));
|
||||
json_object_set_new(rval, "hints_added_time", json_integer(my_instance->stats.n_add_time));
|
||||
|
||||
return rval;
|
||||
}
|
||||
|
@ -298,7 +298,7 @@ static json_t* rules_to_json(RULE *rules)
|
||||
|
||||
for (RULE *rule = rules; rule; rule = rule->next)
|
||||
{
|
||||
json_array_append(rval, rule_to_json(rule));
|
||||
json_array_append_new(rval, rule_to_json(rule));
|
||||
}
|
||||
|
||||
return rval;
|
||||
|
@ -347,7 +347,7 @@ json_t* RegexHintFilter::diagnostics()
|
||||
|
||||
for (StringArray::iterator it2 = it->m_targets.begin(); it2 != it->m_targets.end(); it2++)
|
||||
{
|
||||
json_array_append(targets, json_string(it2->c_str()));
|
||||
json_array_append_new(targets, json_string(it2->c_str()));
|
||||
}
|
||||
|
||||
json_object_set_new(obj, "match", json_string(it->m_match.c_str()));
|
||||
|
@ -621,7 +621,7 @@ static json_t* diagnostic(MXS_FILTER *instance, MXS_FILTER_SESSION *fsession)
|
||||
json_object_set_new(obj, "time", json_real(exec_time));
|
||||
json_object_set_new(obj, "sql", json_string(my_session->top[i]->sql));
|
||||
|
||||
json_array_append(arr, obj);
|
||||
json_array_append_new(arr, obj);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user