ICU-8364 Check the return code when creating hashtable and return null in the case of failure

X-SVN-Rev: 29502
This commit is contained in:
Dragan Besevic 2011-03-01 20:55:43 +00:00
parent 084688bd14
commit 21685ff673
4 changed files with 24 additions and 4 deletions

View file

@ -1,6 +1,6 @@
/*
*******************************************************************************
* Copyright (C) 2009-2010, International Business Machines Corporation and
* Copyright (C) 2009-2011, International Business Machines Corporation and
* others. All Rights Reserved.
*******************************************************************************
*/
@ -349,6 +349,10 @@ CurrencyPluralInfo::initHash(UErrorCode& status) {
status = U_MEMORY_ALLOCATION_ERROR;
return NULL;
}
if ( U_FAILURE(status) ) {
delete hTable;
return NULL;
}
hTable->setValueComparator(ValueComparator);
return hTable;
}

View file

@ -1,6 +1,6 @@
/*
*******************************************************************************
* Copyright (C) 1997-2010, International Business Machines Corporation and *
* Copyright (C) 1997-2011, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*
@ -4491,6 +4491,10 @@ DecimalFormat::initHashForAffix(UErrorCode& status) {
status = U_MEMORY_ALLOCATION_ERROR;
return NULL;
}
if ( U_FAILURE(status) ) {
delete hTable;
return NULL;
}
hTable->setValueComparator(decimfmtAffixValueComparator);
return hTable;
}
@ -4505,6 +4509,10 @@ DecimalFormat::initHashForAffixPattern(UErrorCode& status) {
status = U_MEMORY_ALLOCATION_ERROR;
return NULL;
}
if ( U_FAILURE(status) ) {
delete hTable;
return NULL;
}
hTable->setValueComparator(decimfmtAffixPatternValueComparator);
return hTable;
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (C) 2008-2010, International Business Machines Corporation and
* Copyright (C) 2008-2011, International Business Machines Corporation and
* others. All Rights Reserved.
*******************************************************************************
*
@ -621,6 +621,10 @@ DateIntervalInfo::initHash(UErrorCode& status) {
status = U_MEMORY_ALLOCATION_ERROR;
return NULL;
}
if ( U_FAILURE(status) ) {
delete hTable;
return NULL;
}
hTable->setValueComparator(dtitvinfHashTableValueComparator);
return hTable;
}

View file

@ -1,6 +1,6 @@
/*
*******************************************************************************
* Copyright (C) 2008-2010, Google, International Business Machines Corporation
* Copyright (C) 2008-2011, Google, International Business Machines Corporation
* and others. All Rights Reserved.
*******************************************************************************
*/
@ -837,6 +837,10 @@ TimeUnitFormat::initHash(UErrorCode& status) {
status = U_MEMORY_ALLOCATION_ERROR;
return NULL;
}
if ( U_FAILURE(status) ) {
delete hTable;
return NULL;
}
hTable->setValueComparator(tmutfmtHashTableValueComparator);
return hTable;
}