From df7d633f59c90dba89b11701e6ca8504935e9a86 Mon Sep 17 00:00:00 2001 From: Peter Edberg Date: Wed, 28 Apr 2010 03:55:58 +0000 Subject: [PATCH] ICU-7651 Add test case (segfaults without the fix in r27992) X-SVN-Rev: 27994 --- icu4c/source/test/intltest/regextst.cpp | 39 +++++++++++++++++++++++++ icu4c/source/test/intltest/regextst.h | 1 + 2 files changed, 40 insertions(+) diff --git a/icu4c/source/test/intltest/regextst.cpp b/icu4c/source/test/intltest/regextst.cpp index 185e52caa6f..98748658744 100644 --- a/icu4c/source/test/intltest/regextst.cpp +++ b/icu4c/source/test/intltest/regextst.cpp @@ -98,6 +98,9 @@ void RegexTest::runIndexedTest( int32_t index, UBool exec, const char* &name, ch case 14: name = "PreAllocatedUTextCAPI"; if (exec) PreAllocatedUTextCAPI(); break; + case 15: name = "Bug 7651"; + if (exec) Bug7651(); + break; default: name = ""; break; //needed to end loop @@ -4608,5 +4611,41 @@ void RegexTest::PreAllocatedUTextCAPI () { utext_close(&patternText); } +//-------------------------------------------------------------- +// +// Bug7651 Regex pattern that exceeds default operator stack depth in matcher. +// +//--------------------------------------------------------------- +void RegexTest::Bug7651() { + UnicodeString pattern1("((?matcher(s, status); + REGEX_CHECK_STATUS; + REGEX_ASSERT(REMatcher->find()); + REGEX_ASSERT(REMatcher->start(status) == 0); + delete REPattern; + delete REMatcher; + status = U_ZERO_ERROR; + + REPattern = RegexPattern::compile(pattern2, 0, pe, status); + REGEX_CHECK_STATUS; + REMatcher = REPattern->matcher(s, status); + REGEX_CHECK_STATUS; + REGEX_ASSERT(REMatcher->find()); + REGEX_ASSERT(REMatcher->start(status) == 0); + delete REPattern; + delete REMatcher; + status = U_ZERO_ERROR; + } + #endif /* !UCONFIG_NO_REGULAR_EXPRESSIONS */ diff --git a/icu4c/source/test/intltest/regextst.h b/icu4c/source/test/intltest/regextst.h index 3bf592210d3..627ad5b249f 100644 --- a/icu4c/source/test/intltest/regextst.h +++ b/icu4c/source/test/intltest/regextst.h @@ -40,6 +40,7 @@ public: virtual void API_Replace_UTF8(); virtual void PerlTestsUTF8(); virtual void PreAllocatedUTextCAPI(); + virtual void Bug7651(); // The following functions are internal to the regexp tests. virtual void assertUText(const char *expected, UText *actual, const char *file, int line);