MXS-3087: Fix diagnostic memory leaks

Fixed leak in load_utils.cc and the cache filter. Also changed all
instances of json_object_set with json_object_set_new to make sure it's
only used when the references are to be stolen.
This commit is contained in:
Markus Mäkelä 2020-07-22 13:27:36 +03:00
parent 0e5163a3fb
commit cf1d1178d7
No known key found for this signature in database
GPG Key ID: 5CE746D557ACC499
6 changed files with 8 additions and 14 deletions

View File

@ -530,7 +530,7 @@ static json_t* module_json_data(const LOADED_MODULE* mod, const char* host)
if (mod->info->parameters[i].default_value)
{
json_object_set(p, "default_value", json_string(mod->info->parameters[i].default_value));
json_object_set_new(p, "default_value", json_string(mod->info->parameters[i].default_value));
}
if (mod->info->parameters[i].type == MXS_MODULE_PARAM_ENUM

View File

@ -202,7 +202,7 @@ json_t* Cache::do_get_info(uint32_t what) const
// failure.
}
json_object_set(pInfo, "rules", pArray);
json_object_set_new(pInfo, "rules", pArray);
}
}
}

View File

@ -112,8 +112,7 @@ json_t* CachePT::get_info(uint32_t what) const
if (pThreadInfo)
{
json_object_set(pInfo, key, pThreadInfo);
json_decref(pThreadInfo);
json_object_set_new(pInfo, key, pThreadInfo);
}
}
}

View File

@ -90,8 +90,7 @@ json_t* CacheSimple::do_get_info(uint32_t what) const
if (CACHE_RESULT_IS_OK(result))
{
json_object_set(pInfo, "storage", pStorageInfo);
json_decref(pStorageInfo);
json_object_set_new(pInfo, "storage", pStorageInfo);
}
}

View File

@ -54,8 +54,7 @@ cache_result_t LRUStorage::do_get_info(uint32_t what,
{
m_stats.fill(pLru);
json_object_set(*ppInfo, "lru", pLru);
json_decref(pLru);
json_object_set_new(*ppInfo, "lru", pLru);
}
json_t* pStorage_info;
@ -64,8 +63,7 @@ cache_result_t LRUStorage::do_get_info(uint32_t what,
if (CACHE_RESULT_IS_OK(result))
{
json_object_set(*ppInfo, "real_storage", pStorage_info);
json_decref(pStorage_info);
json_object_set_new(*ppInfo, "real_storage", pStorage_info);
}
}
@ -593,8 +591,7 @@ static void set_integer(json_t* pObject, const char* zName, size_t value)
if (pValue)
{
json_object_set(pObject, zName, pValue);
json_decref(pValue);
json_object_set_new(pObject, zName, pValue);
}
}

View File

@ -281,8 +281,7 @@ static void set_integer(json_t* pObject, const char* zName, size_t value)
if (pValue)
{
json_object_set(pObject, zName, pValue);
json_decref(pValue);
json_object_set_new(pObject, zName, pValue);
}
}