summaryrefslogtreecommitdiff
path: root/src/mongo/db/query/plan_executor_sbe.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/query/plan_executor_sbe.cpp')
-rw-r--r--src/mongo/db/query/plan_executor_sbe.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/mongo/db/query/plan_executor_sbe.cpp b/src/mongo/db/query/plan_executor_sbe.cpp
index b4905fce9ec..a62dfc5b8aa 100644
--- a/src/mongo/db/query/plan_executor_sbe.cpp
+++ b/src/mongo/db/query/plan_executor_sbe.cpp
@@ -89,6 +89,10 @@ PlanExecutorSBE::PlanExecutorSBE(OperationContext* opCtx,
if (!winner.results.empty()) {
_stash = std::move(winner.results);
+ // The PlanExecutor keeps an extra reference to the last object pulled out of the PlanStage
+ // tree. This is because we want to ensure that the caller of PlanExecutor::getNext() does
+ // not free the object and leave a dangling pointer in the PlanStage tree.
+ _lastGetNext = _stash.back().first;
}
// Callers are allowed to disable yielding for this plan by passing a null yield policy.