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:03:25 -0400
commitdb0ba62bd4a375f86e36c992033894569233000f (patch)
treef3c690a2c801e93aa5a46b0645eb2e4043a52912
parent45f759ee98ac74c7626dc4bc52db2a5120448b19 (diff)
downloadmongo-db0ba62bd4a375f86e36c992033894569233000f.tar.gz
SERVER-18086 fix leak in QueryPlanner::planFromCache
-rw-r--r--src/mongo/db/query/query_planner.cpp16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/mongo/db/query/query_planner.cpp b/src/mongo/db/query/query_planner.cpp
index 87b4fb6b2f2..570b01b326e 100644
--- a/src/mongo/db/query/query_planner.cpp
+++ b/src/mongo/db/query/query_planner.cpp
@@ -52,6 +52,7 @@ namespace mongo {
using std::auto_ptr;
using std::numeric_limits;
+ using std::unique_ptr;
// Copied verbatim from db/index.h
static bool isIdIndex( const BSONObj &pattern ) {
@@ -374,7 +375,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();
+ unique_ptr<MatchExpression> clone(query.root()->shallowClone());
QLOG() << "Tagging the match expression according to cache data: " << endl
<< "Filter:" << endl << clone->toString()
@@ -390,19 +391,22 @@ 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, params);
+ // Use the cached index assignments to build solnRoot.
+ QuerySolutionNode* solnRoot = QueryPlannerAccess::buildIndexedDataAccess(query,
+ clone.release(),
+ false,
+ params.indices,
+ params);
if (NULL != solnRoot) {
// Takes ownership of 'solnRoot'.