From ad4bd26ff0d2bf509f29a738d421124920b6099a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Fri, 3 Jul 2020 05:47:44 +0300 Subject: [PATCH] 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. --- server/modules/filter/cache/lrustorage.cc | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/server/modules/filter/cache/lrustorage.cc b/server/modules/filter/cache/lrustorage.cc index a1454929b..9523597ef 100644 --- a/server/modules/filter/cache/lrustorage.cc +++ b/server/modules/filter/cache/lrustorage.cc @@ -551,11 +551,6 @@ cache_result_t LRUStorage::get_new_node(const CACHE_KEY& key, mxb_assert(m_stats.items == m_max_count); pNode = vacate_lru(); } - - if (!pNode) - { - result = CACHE_RESULT_ERROR; - } } else { @@ -578,6 +573,10 @@ cache_result_t LRUStorage::get_new_node(const CACHE_KEY& key, result = CACHE_RESULT_OUT_OF_RESOURCES; } } + else + { + result = CACHE_RESULT_ERROR; + } if (CACHE_RESULT_IS_OK(result)) {