aboutsummaryrefslogtreecommitdiff
path: root/source/test/intltest/regextst.cpp
diff options
context:
space:
mode:
authorBen Murdoch <benm@google.com>2014-12-04 17:01:02 +0000
committerBen Murdoch <benm@google.com>2014-12-04 17:01:02 +0000
commitdb11affe221d592343cb77d5cc86f6aaed375d96 (patch)
treefe77fe54e4d82fc1ce2574c02e47ffa451a41d13 /source/test/intltest/regextst.cpp
parente318d1364cbed337f3c792dc0727677bf0886c77 (diff)
parentdd727641e190d60e4593bcb3a35c7f51eb4925c5 (diff)
downloadicu-db11affe221d592343cb77d5cc86f6aaed375d96.tar.gz
Merge third_party/icu from https://chromium.googlesource.com/chromium/deps/icu52.git at dd727641e190d60e4593bcb3a35c7f51eb4925c5
This commit was generated by merge_from_chromium.py. Change-Id: Ic90a8ea9f1d961d596a5f983d48bf309af696d1d
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 */