MXS-2585: Check for failed allocations
Since nothrow was used, the return value should be checked. By moving the null-check after the node allocation part, we'll detect it.
This commit is contained in:
9
server/modules/filter/cache/lrustorage.cc
vendored
9
server/modules/filter/cache/lrustorage.cc
vendored
@ -551,11 +551,6 @@ cache_result_t LRUStorage::get_new_node(const CACHE_KEY& key,
|
|||||||
mxb_assert(m_stats.items == m_max_count);
|
mxb_assert(m_stats.items == m_max_count);
|
||||||
pNode = vacate_lru();
|
pNode = vacate_lru();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!pNode)
|
|
||||||
{
|
|
||||||
result = CACHE_RESULT_ERROR;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -578,6 +573,10 @@ cache_result_t LRUStorage::get_new_node(const CACHE_KEY& key,
|
|||||||
result = CACHE_RESULT_OUT_OF_RESOURCES;
|
result = CACHE_RESULT_OUT_OF_RESOURCES;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
result = CACHE_RESULT_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
if (CACHE_RESULT_IS_OK(result))
|
if (CACHE_RESULT_IS_OK(result))
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user