mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-09 15:27:38 +00:00
ICU-6813 parameter validation to uregex_appendReplacement()
X-SVN-Rev: 25660
This commit is contained in:
parent
23845c6ec2
commit
c567c8c1b1
2 changed files with 10 additions and 1 deletions
|
@ -883,7 +883,7 @@ int32_t RegexCImpl::appendReplacement(URegularExpression *regexp,
|
|||
// A series of appendReplacements, appendTail need to correctly preflight
|
||||
// the buffer size when an overflow happens somewhere in the middle.
|
||||
UBool pendingBufferOverflow = FALSE;
|
||||
if (*status == U_BUFFER_OVERFLOW_ERROR && *destCapacity == 0) {
|
||||
if (*status == U_BUFFER_OVERFLOW_ERROR && destCapacity != NULL && *destCapacity == 0) {
|
||||
pendingBufferOverflow = TRUE;
|
||||
*status = U_ZERO_ERROR;
|
||||
}
|
||||
|
|
|
@ -948,6 +948,15 @@ static void TestRegexCAPI(void) {
|
|||
TEST_ASSERT_SUCCESS(status);
|
||||
TEST_ASSERT_STRING("abcAB \\ $ abc", buf, TRUE);
|
||||
|
||||
/* Bug 6813, parameter check of NULL destCapacity; crashed before fix. */
|
||||
status = U_ZERO_ERROR;
|
||||
uregex_find(re, 0, &status);
|
||||
TEST_ASSERT_SUCCESS(status);
|
||||
bufPtr = buf;
|
||||
status = U_BUFFER_OVERFLOW_ERROR;
|
||||
uregex_appendReplacement(re, repl, -1, &bufPtr, NULL, &status);
|
||||
TEST_ASSERT(status == U_BUFFER_OVERFLOW_ERROR);
|
||||
|
||||
uregex_close(re);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue