summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorQingyang Chen <qingyang.chen@10gen.com>2015-07-01 15:31:09 -0400
committerQingyang Chen <qingyang.chen@10gen.com>2015-07-01 18:01:30 -0400
commit16d594b5d2ca3ee0466513eb5d392d0e59084dac (patch)
tree64f9edcd5c0d5b47107c33f057f56c3556c1c4b3
parentdd56a8285ff95bcb4bf185710a483a150ccf29ca (diff)
downloadmongo-16d594b5d2ca3ee0466513eb5d392d0e59084dac.tar.gz
SERVER-18086 fix leak in QueryPlanner::planFromCache
-rw-r--r--src/mongo/db/query/query_planner.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/mongo/db/query/query_planner.cpp b/src/mongo/db/query/query_planner.cpp
index 470b619151a..2ebd0b51834 100644
--- a/src/mongo/db/query/query_planner.cpp
+++ b/src/mongo/db/query/query_planner.cpp
@@ -361,7 +361,7 @@ namespace mongo {
// cases, and we proceed by using the PlanCacheIndexTree to tag the query tree.
// Create a copy of the expression tree. We use cachedSoln to annotate this with indices.
- MatchExpression* clone = query.root()->shallowClone();
+ auto_ptr<MatchExpression> clone(query.root()->shallowClone());
QLOG() << "Tagging the match expression according to cache data: " << endl
<< "Filter:" << endl << clone->toString()
@@ -377,19 +377,21 @@ namespace mongo {
QLOG() << "Index " << i << ": " << ie.keyPattern.toString() << endl;
}
- Status s = tagAccordingToCache(clone, cacheData.tree.get(), indexMap);
+ Status s = tagAccordingToCache(clone.get(), cacheData.tree.get(), indexMap);
if (!s.isOK()) {
return s;
}
// The planner requires a defined sort order.
- sortUsingTags(clone);
+ sortUsingTags(clone.get());
QLOG() << "Tagged tree:" << endl << clone->toString();
- // Use the cached index assignments to build solnRoot. Takes ownership of clone.
- QuerySolutionNode* solnRoot =
- QueryPlannerAccess::buildIndexedDataAccess(query, clone, false, params.indices);
+ // Use the cached index assignments to build solnRoot.
+ QuerySolutionNode* solnRoot = QueryPlannerAccess::buildIndexedDataAccess(query,
+ clone.release(),
+ false,
+ params.indices);
if (NULL != solnRoot) {
// Takes ownership of 'solnRoot'.