summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Larkin-York <dan.larkin-york@mongodb.com>2022-03-14 17:43:57 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-03-14 18:35:09 +0000
commitf59871be9db084e1148af7c685239d22819e3273 (patch)
tree4d5c5b2a1eef0e9187a677cb43574eaa38068da4
parent353307a5cee706318068b07527c32bcbfdb92558 (diff)
downloadmongo-f59871be9db084e1148af7c685239d22819e3273.tar.gz
SERVER-64451 Ensure we don't try to access BoundedSorter heap if it is empty
-rw-r--r--src/mongo/db/sorter/sorter.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/mongo/db/sorter/sorter.cpp b/src/mongo/db/sorter/sorter.cpp
index 7174d893f9d..e520d6d4c23 100644
--- a/src/mongo/db/sorter/sorter.cpp
+++ b/src/mongo/db/sorter/sorter.cpp
@@ -1402,7 +1402,7 @@ BoundedSorter<Key, Value, Comparator, BoundMaker>::getState() const {
// _heap.top() is the min of _heap, but we also need to consider whether a smaller input
// will arrive later. So _heap.top() is safe to return only if _heap.top() < _min.
- if (compare(_heap.top().first, *_min) < 0)
+ if (!_heap.empty() && compare(_heap.top().first, *_min) < 0)
return State::kReady;
// Similarly, we can return the next element from the spilled iterator if it's < _min.