summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Rassi <rassi@10gen.com>2014-08-19 16:14:46 -0400
committerJason Rassi <rassi@10gen.com>2014-08-20 14:16:13 -0400
commit2b23514f91c1ab0cc6b8f7e928138fbf513ce34e (patch)
tree9b28b174251f164b52708d31be9910353f5cbbd6
parent1921d143fed7ac144933edbb17724e96a6ab7bd6 (diff)
downloadmongo-2b23514f91c1ab0cc6b8f7e928138fbf513ce34e.tar.gz
SERVER-14892 Fix memory leak in MatchExpressionParser::_parseElemMatch
(cherry picked from commit cc80c4d9a0556926a3f3fa9556c95ffd56aa4814)
-rw-r--r--src/mongo/db/matcher/expression_parser.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/mongo/db/matcher/expression_parser.cpp b/src/mongo/db/matcher/expression_parser.cpp
index e8b1ad250ce..ff4072725f7 100644
--- a/src/mongo/db/matcher/expression_parser.cpp
+++ b/src/mongo/db/matcher/expression_parser.cpp
@@ -701,19 +701,20 @@ namespace mongo {
// object case
- StatusWithMatchExpression sub = _parse( obj, level );
- if ( !sub.isOK() )
- return sub;
+ StatusWithMatchExpression subRaw = _parse( obj, level );
+ if ( !subRaw.isOK() )
+ return subRaw;
+ std::auto_ptr<MatchExpression> sub( subRaw.getValue() );
// $where is not supported under $elemMatch because $where
// applies to top-level document, not array elements in a field.
- if ( hasNode( sub.getValue(), MatchExpression::WHERE ) ) {
+ if ( hasNode( sub.get(), MatchExpression::WHERE ) ) {
return StatusWithMatchExpression( ErrorCodes::BadValue,
"$elemMatch cannot contain $where expression" );
}
std::auto_ptr<ElemMatchObjectMatchExpression> temp( new ElemMatchObjectMatchExpression() );
- Status status = temp->init( name, sub.getValue() );
+ Status status = temp->init( name, sub.release() );
if ( !status.isOK() )
return StatusWithMatchExpression( status );