ICU-6813 parameter validation to uregex_appendReplacement()

X-SVN-Rev: 25660
This commit is contained in:
Andy Heninger 2009-03-26 23:04:40 +00:00
parent 23845c6ec2
commit c567c8c1b1
2 changed files with 10 additions and 1 deletions

View file

@ -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;
}

View file

@ -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);
}