From 16d4a7b5b6f549199da96badcc6eba899b8c15fc Mon Sep 17 00:00:00 2001 From: Vinko Kasljevic Date: Tue, 7 May 2019 14:44:24 +0200 Subject: [PATCH] Add nullptr check in LruList Summary: Clang-analyzer-core found NullDereference issue in LruList. I don't see how that can occur, but as a precaution I'll add a CHECK. Reviewers: msantl, ipaljak Reviewed By: msantl Subscribers: pullbot Differential Revision: https://phabricator.memgraph.io/D2015 --- src/utils/cache.hpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/utils/cache.hpp b/src/utils/cache.hpp index 53bbee69d..41009d203 100644 --- a/src/utils/cache.hpp +++ b/src/utils/cache.hpp @@ -31,6 +31,8 @@ class LruList { if (!front_ && !rear_) { front_ = rear_ = page; } else { + CHECK(front_ != nullptr && rear_ != nullptr) + << "Both front_ and rear_ must be valid"; page->next = front_; front_->prev = page; front_ = page; @@ -39,6 +41,8 @@ class LruList { } void MovePageToHead(Node *page) { + CHECK(front_ != nullptr && rear_ != nullptr) + << "Both front_ and rear_ must be valid"; if (page == front_) { return; } @@ -55,6 +59,7 @@ class LruList { front_->prev = page; front_ = page; } + void RemoveRearPage() { if (IsEmpty()) { return;