ICU-1739 fixed a memory access error

X-SVN-Rev: 9566
This commit is contained in:
George Rhoten 2002-08-03 05:58:30 +00:00
parent 963d1278e3
commit bf75d537d3
2 changed files with 37 additions and 38 deletions

View File

@ -783,9 +783,9 @@ TestInvalidRules(){
UParseError parseError;
UErrorCode status = U_ZERO_ERROR;
UCollator* coll=0;
u_charsToUChars(rulesArr[i],rules,1000);
u_charsToUChars(preContextArr[i],preContextExp,1000);
u_charsToUChars(postContextArr[i],postContextExp,1000);
u_charsToUChars(rulesArr[i],rules,uprv_strlen(rulesArr[i])+1);
u_charsToUChars(preContextArr[i],preContextExp,uprv_strlen(preContextArr[i])+1);
u_charsToUChars(postContextArr[i],postContextExp,uprv_strlen(postContextArr[i])+1);
/* clean up stuff in parseError */
u_memset(parseError.preContext,0x0000,U_PARSE_CONTEXT_LEN);
u_memset(parseError.postContext,0x0000,U_PARSE_CONTEXT_LEN);

View File

@ -4662,44 +4662,43 @@ TestLMBCS() {
UChar * OutLimit = Out + sizeof(pszUnicode)/sizeof(UChar);
cnv = ucnv_open(NAME_LMBCS_1, &errorCode);
if(U_FAILURE(errorCode)) {
log_err("Unable to open a LMBCS-1 converter: %s\n", u_errorName(errorCode));
return;
}
cnv = ucnv_open(NAME_LMBCS_1, &errorCode);
if(U_FAILURE(errorCode)) {
log_err("Unable to open a LMBCS-1 converter: %s\n", u_errorName(errorCode));
return;
}
while ((pSource < sourceLimit) && U_SUCCESS (errorCode))
{
ucnv_toUnicode (cnv,
&pOut,
OutLimit,
(const char **)&pSource,
(const char *)(pSource+1), /* claim that this is a 1- byte buffer */
NULL,
FALSE, /* FALSE means there might be more chars in the next buffer */
&errorCode);
if (U_SUCCESS (errorCode))
{
if ((pSource - (const uint8_t *)pszLMBCS) == offsets [codepointCount+1])
{
/* we are on to the next code point: check value */
if (Out[0] != pszUnicode[codepointCount]){
log_err("LMBCS->Uni result %lx should have been %lx \n",
Out[0], pszUnicode[codepointCount]);
ucnv_toUnicode (cnv,
&pOut,
OutLimit,
(const char **)&pSource,
(const char *)(pSource+1), /* claim that this is a 1- byte buffer */
NULL,
FALSE, /* FALSE means there might be more chars in the next buffer */
&errorCode);
if (U_SUCCESS (errorCode))
{
if ((pSource - (const uint8_t *)pszLMBCS) == offsets [codepointCount+1])
{
/* we are on to the next code point: check value */
if (Out[0] != pszUnicode[codepointCount]){
log_err("LMBCS->Uni result %lx should have been %lx \n",
Out[0], pszUnicode[codepointCount]);
}
pOut = Out; /* reset for accumulating next code point */
codepointCount++;
}
pOut = Out; /* reset for accumulating next code point */
codepointCount++;
}
}
else
{
log_err("Unexpected Error on toUnicode: %s\n", u_errorName(errorCode));
}
}
else
{
log_err("Unexpected Error on toUnicode: %s\n", u_errorName(errorCode));
}
}
{
/* limits & surrogate error testing */