ICU-6132 Add memory check in constructor and copy constructor.
X-SVN-Rev: 23264
This commit is contained in:
parent
a7aefadebd
commit
7f7c4f490a
@ -1,6 +1,6 @@
|
||||
/*
|
||||
**********************************************************************
|
||||
* Copyright (C) 1999-2007, International Business Machines
|
||||
* Copyright (C) 1999-2008, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
**********************************************************************
|
||||
* Date Name Description
|
||||
@ -162,6 +162,9 @@ U_NAMESPACE_BEGIN
|
||||
*/
|
||||
TransliterationRuleSet::TransliterationRuleSet(UErrorCode& status) : UMemory() {
|
||||
ruleVector = new UVector(&_deleteRule, NULL, status);
|
||||
if (U_FAILURE(status)) {
|
||||
return;
|
||||
}
|
||||
rules = NULL;
|
||||
maxContextLength = 0;
|
||||
if (ruleVector == NULL) {
|
||||
@ -185,11 +188,19 @@ TransliterationRuleSet::TransliterationRuleSet(const TransliterationRuleSet& oth
|
||||
if (other.ruleVector != 0 && ruleVector != 0 && U_SUCCESS(status)) {
|
||||
len = other.ruleVector->size();
|
||||
for (i=0; i<len && U_SUCCESS(status); ++i) {
|
||||
ruleVector->addElement(new TransliterationRule(
|
||||
*(TransliterationRule*)other.ruleVector->elementAt(i)), status);
|
||||
TransliterationRule *tempTranslitRule = new TransliterationRule(*(TransliterationRule*)other.ruleVector->elementAt(i));
|
||||
// Null pointer test
|
||||
if (tempTranslitRule == NULL) {
|
||||
status = U_MEMORY_ALLOCAITON_ERROR;
|
||||
break;
|
||||
}
|
||||
ruleVector->addElement(tempTranslitRule, status);
|
||||
if (U_FAILURE(status)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (other.rules != 0) {
|
||||
if (other.rules != 0 && U_SUCCESS(status)) {
|
||||
UParseError p;
|
||||
freeze(p, status);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user