summaryrefslogtreecommitdiff
path: root/src
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:47 -0400
commit71277e8a5d072fbfa956a74f3c0295f69ead120f (patch)
treeea7ca0674c85927be0980d24abcb1a5c61930dac /src
parent562c8cb3faff5e9fc0acdc45db8dc2d498eb2000 (diff)
downloadmongo-71277e8a5d072fbfa956a74f3c0295f69ead120f.tar.gz
SERVER-14892 Fix memory leak in MatchExpressionParser::_parseElemMatch
Diffstat (limited to 'src')
-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 ff82ffbdb79..120c290f6a0 100644
--- a/src/mongo/db/matcher/expression_parser.cpp
+++ b/src/mongo/db/matcher/expression_parser.cpp
@@ -696,19 +696,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 );