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
This commit is contained in:
Vinko Kasljevic 2019-05-07 14:44:24 +02:00
parent 0849937aea
commit 16d4a7b5b6

View File

@ -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<TKey, TValue> *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;