summaryrefslogtreecommitdiff
path: root/src/mongo/db/matcher/expression_where.cpp
diff options
context:
space:
mode:
authorAndy Schwerin <schwerin@mongodb.com>2015-06-18 15:07:45 -0400
committerAndy Schwerin <schwerin@mongodb.com>2015-06-19 08:35:44 -0400
commitf1f528db6bbf170bd915c421ec93a66716234587 (patch)
treeabb1a1e1a253c54d49f3d56e9bc220e21d7e53b5 /src/mongo/db/matcher/expression_where.cpp
parent330a052a6a9125dd96ec4e6c360a551f06ed922e (diff)
downloadmongo-f1f528db6bbf170bd915c421ec93a66716234587.tar.gz
SERVER-19040 Do not let exceptions leak out of WhereMatchExpression::init.
Diffstat (limited to 'src/mongo/db/matcher/expression_where.cpp')
-rw-r--r--src/mongo/db/matcher/expression_where.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/mongo/db/matcher/expression_where.cpp b/src/mongo/db/matcher/expression_where.cpp
index 290b2bc3071..adbfe6172d2 100644
--- a/src/mongo/db/matcher/expression_where.cpp
+++ b/src/mongo/db/matcher/expression_where.cpp
@@ -117,9 +117,12 @@ namespace mongo {
const string userToken = AuthorizationSession::get(ClientBasic::getCurrent())
->getAuthenticatedUserNamesToken();
- _scope = globalScriptEngine->getPooledScope(_txn, _dbName, "where" + userToken);
-
- _func = _scope->createFunction( _code.c_str() );
+ try {
+ _scope = globalScriptEngine->getPooledScope(_txn, _dbName, "where" + userToken);
+ _func = _scope->createFunction(_code.c_str());
+ } catch (...) {
+ return exceptionToStatus();
+ }
if ( !_func )
return Status( ErrorCodes::BadValue, "$where compile error" );
@@ -128,7 +131,7 @@ namespace mongo {
}
bool WhereMatchExpression::matches( const MatchableDocument* doc, MatchDetails* details ) const {
- verify( _func );
+ uassert(28689, "$where compile error", _func);
BSONObj obj = doc->toBSON();
if ( ! _userScope.isEmpty() ) {