ICU-6076 Fix allocation failure recovery problems.

X-SVN-Rev: 23460
This commit is contained in:
George Rhoten 2008-02-19 07:53:15 +00:00
parent 24e86c8cab
commit 5a8942d749
2 changed files with 14 additions and 5 deletions

View File

@ -650,8 +650,7 @@ ZoneStringFormat::ZoneStringFormat(const Locale &locale, UErrorCode &status)
ZoneStringInfo *zsinfo = new ZoneStringInfo(preferredIdForLocale, strings_mz[typeidx], (TimeZoneTranslationType)type);
fZoneStringsTrie.put(strings_mz[typeidx], zsinfo, status);
if (U_FAILURE(status)) {
delete zsinfo;
delete strings_mz;
delete []strings_mz;
goto error_cleanup;
}
}
@ -664,7 +663,6 @@ ZoneStringFormat::ZoneStringFormat(const Locale &locale, UErrorCode &status)
fMzidToStrings.put(mzid, tmp_mzStrings, status);
if (U_FAILURE(status)) {
delete tmp_mzStrings;
goto error_cleanup;
}
@ -1560,6 +1558,11 @@ ZSFCache::get(const Locale &locale, UErrorCode &status) {
if (entry == NULL) {
ZoneStringFormat *zsf = new ZoneStringFormat(locale, status);
if (U_FAILURE(status)) {
delete zsf;
return NULL;
}
if (zsf == NULL) {
status = U_MEMORY_ALLOCATION_ERROR;
return NULL;
}
// Now add the new entry

View File

@ -1,6 +1,6 @@
/********************************************************************
* COPYRIGHT:
* Copyright (c) 1997-2007, International Business Machines Corporation and
* Copyright (c) 1997-2008, International Business Machines Corporation and
* others. All Rights Reserved.
********************************************************************/
/* file name: cbiditst.cpp
@ -1758,6 +1758,10 @@ testMultipleParagraphs(void) {
ubidi_orderParagraphsLTR(pBidi, TRUE);
ubidi_setPara(pBidi, src, srcSize, UBIDI_RTL, NULL, &errorCode);
gotLevels=ubidi_getLevels(pBidi, &errorCode);
if (U_FAILURE(errorCode)) {
log_err("Can't get levels. %s\n", u_errorName(errorCode));
return;
}
for (i=0; i<srcSize; i++) {
if (gotLevels[i]!=levels2[i]) {
log_err("Checking leading numerics: for char %d(%04x), level=%d, expected=%d\n",
@ -3553,7 +3557,9 @@ testStreaming(void) {
len = chunk < srcLen ? chunk : srcLen;
ubidi_setPara(pBiDi, pSrc, len, level, NULL, &rc);
assertSuccessful("ubidi_setPara", &rc);
if (!assertSuccessful("ubidi_setPara", &rc)) {
break;
}
processedLen = ubidi_getProcessedLength(pBiDi);
if (processedLen == 0) {