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:
parent
0e5163a3fb
commit
cf1d1178d7
@ -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
|
||||
|
2
server/modules/filter/cache/cache.cc
vendored
2
server/modules/filter/cache/cache.cc
vendored
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
3
server/modules/filter/cache/cachept.cc
vendored
3
server/modules/filter/cache/cachept.cc
vendored
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
3
server/modules/filter/cache/cachesimple.cc
vendored
3
server/modules/filter/cache/cachesimple.cc
vendored
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
9
server/modules/filter/cache/lrustorage.cc
vendored
9
server/modules/filter/cache/lrustorage.cc
vendored
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user