summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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 );