From 8766bb44b133a637c5c13709e6ffc607a53af282 Mon Sep 17 00:00:00 2001 From: Andrew Noyes Date: Tue, 9 Mar 2021 01:40:59 +0000 Subject: [PATCH] Address review comment --- fdbserver/DeltaTree.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/fdbserver/DeltaTree.h b/fdbserver/DeltaTree.h index 860f7fc22f..7c32e24ab5 100644 --- a/fdbserver/DeltaTree.h +++ b/fdbserver/DeltaTree.h @@ -386,7 +386,11 @@ public: // have changed (they won't if k already exists in the tree but was deleted). // Returns true if successful, false if k does not fit in the space available // or if k is already in the tree (and was not already deleted). + // Insertion on an empty tree returns false as well. bool insert(const T& k, int skipLen = 0, int maxHeightAllowed = std::numeric_limits::max()) { + if (root == nullptr) { + return false; + } int height = 1; DecodedNode* n = root; bool addLeftChild = false; @@ -432,7 +436,6 @@ public: return false; } - ASSERT(n != nullptr); // Insert k as the left or right child of n, depending on the value of addLeftChild // First, see if it will fit. const T* prev = addLeftChild ? n->prev : &n->item;