aboutsummaryrefslogtreecommitdiff
path: root/source/test/intltest/regextst.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/test/intltest/regextst.cpp')
-rw-r--r--source/test/intltest/regextst.cpp47
1 files changed, 46 insertions, 1 deletions
diff --git a/source/test/intltest/regextst.cpp b/source/test/intltest/regextst.cpp
index 8e750c9..9fd9f43 100644
--- a/source/test/intltest/regextst.cpp
+++ b/source/test/intltest/regextst.cpp
@@ -131,6 +131,9 @@ void RegexTest::runIndexedTest( int32_t index, UBool exec, const char* &name, ch
case 21: name = "Bug 9283";
if (exec) Bug9283();
break;
+ case 22: name = "TestBug11371";
+ if (exec) TestBug11371();
+ break;
default: name = "";
break; //needed to end loop
@@ -5229,5 +5232,47 @@ void RegexTest::CheckInvBufSize() {
}
}
-#endif /* !UCONFIG_NO_REGULAR_EXPRESSIONS */
+void RegexTest::TestBug11371() {
+ UErrorCode status = U_ZERO_ERROR;
+ UnicodeString patternString;
+
+ for (int i=0; i<8000000; i++) {
+ patternString.append(UnicodeString("()"));
+ }
+ LocalPointer<RegexPattern> compiledPat(RegexPattern::compile(patternString, 0, status));
+ if (status != U_REGEX_PATTERN_TOO_BIG) {
+ errln("File %s, line %d expected status=U_REGEX_PATTERN_TOO_BIG; got %s.",
+ __FILE__, __LINE__, u_errorName(status));
+ }
+
+ status = U_ZERO_ERROR;
+ patternString = "(";
+ for (int i=0; i<20000000; i++) {
+ patternString.append(UnicodeString("A++"));
+ }
+ patternString.append(UnicodeString("){0}B++"));
+ LocalPointer<RegexPattern> compiledPat2(RegexPattern::compile(patternString, 0, status));
+ if (status != U_REGEX_PATTERN_TOO_BIG) {
+ errln("File %s, line %d expected status=U_REGEX_PATTERN_TOO_BIG; got %s.",
+ __FILE__, __LINE__, u_errorName(status));
+ }
+ // Pattern with too much string data, such that string indexes overflow operand data.
+ status = U_ZERO_ERROR;
+ patternString = "";
+ while (patternString.length() < 0x00ffffff) {
+ patternString.append(UnicodeString("stuff and things dont you know, these are a few of my favorite strings\n"));
+ }
+ patternString.append(UnicodeString("X? trailing string"));
+ LocalPointer<RegexPattern> compiledPat3(RegexPattern::compile(patternString, 0, status));
+ compiledPat3->dumpPattern();
+ if (status != U_REGEX_PATTERN_TOO_BIG) {
+ errln("File %s, line %d expected status=U_REGEX_PATTERN_TOO_BIG; got %s.",
+ __FILE__, __LINE__, u_errorName(status));
+ }
+
+
+
+}
+
+#endif /* !UCONFIG_NO_REGULAR_EXPRESSIONS */