summaryrefslogtreecommitdiff
path: root/src/mongo/db/pipeline/expression.cpp
diff options
context:
space:
mode:
authorArun Banala <arun.banala@mongodb.com>2019-03-28 14:36:10 +0000
committerArun Banala <arun.banala@mongodb.com>2019-04-01 15:44:19 +0100
commit1d8ddd2d2d480bc0b840b506c3630c82be8c09a2 (patch)
tree0261c9dffbe39bd7bfb0348e8b029b0b5446f8bd /src/mongo/db/pipeline/expression.cpp
parentb6761b00896e78c1e30e565ee82752bcc7d252f0 (diff)
downloadmongo-1d8ddd2d2d480bc0b840b506c3630c82be8c09a2.tar.gz
SERVER-40343 Better handling of errors from PCRE in $regex expressions
Diffstat (limited to 'src/mongo/db/pipeline/expression.cpp')
-rw-r--r--src/mongo/db/pipeline/expression.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/mongo/db/pipeline/expression.cpp b/src/mongo/db/pipeline/expression.cpp
index cebc922084f..f842c88c1c9 100644
--- a/src/mongo/db/pipeline/expression.cpp
+++ b/src/mongo/db/pipeline/expression.cpp
@@ -5681,10 +5681,15 @@ public:
0, // No need to overwrite the options set during pcre_compile.
&_capturesBuffer.front(),
_capturesBuffer.size());
- // The 'execResult' will be '(_numCaptures + 1)' if there is a match, negative if there is
- // no match, and zero if _capturesBuffer's capacity is not sufficient to hold all the
- // results; the latter scenario should never actually occur.
- invariant(execResult < 0 || execResult == _numCaptures + 1);
+ // The 'execResult' will be (_numCaptures + 1) if there is a match, -1 if there is no
+ // match, negative if there is an error during execution, and zero if _capturesBuffer's
+ // capacity is not sufficient to hold all the results. The latter scenario should never
+ // occur.
+ uassert(
+ 51156,
+ str::stream() << "Error occurred while executing the regular expression. Result code:"
+ << execResult,
+ execResult == -1 || execResult == (_numCaptures + 1));
return execResult;
}