ICU-6132 Add memory check for rbnf, rbt, and rbt_data.
X-SVN-Rev: 23230
This commit is contained in:
parent
c5e68bd1f8
commit
b32b3d69dc
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 1997-2006, International Business Machines Corporation
|
||||
* Copyright (C) 1997-2008, International Business Machines Corporation
|
||||
* and others. All Rights Reserved.
|
||||
*******************************************************************************
|
||||
*/
|
||||
@ -1490,6 +1490,10 @@ RuleBasedNumberFormat::getCollator() const
|
||||
rules.append(*lenientParseRules);
|
||||
|
||||
newCollator = new RuleBasedCollator(rules, status);
|
||||
// Exit if newCollator could not be created.
|
||||
if (newCollator == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
} else {
|
||||
temp = NULL;
|
||||
}
|
||||
|
@ -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
|
||||
@ -257,12 +257,14 @@ RuleBasedTransliterator::handleTransliterate(Replaceable& text, UTransPosition&
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Check to make sure we don't dereference a null pointer.
|
||||
if (fData != NULL) {
|
||||
while (index.start < index.limit &&
|
||||
loopCount <= loopLimit &&
|
||||
fData->ruleSet.transliterate(text, index, isIncremental)) {
|
||||
++loopCount;
|
||||
}
|
||||
}
|
||||
if (lockedMutexAtThisLevel) {
|
||||
gLockedText = NULL;
|
||||
umtx_unlock(&transliteratorDataMutex);
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
**********************************************************************
|
||||
* Copyright (C) 1999-2006, International Business Machines
|
||||
* Copyright (C) 1999-2008, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
**********************************************************************
|
||||
* Date Name Description
|
||||
@ -40,12 +40,17 @@ TransliterationRuleData::TransliterationRuleData(const TransliterationRuleData&
|
||||
variablesLength(other.variablesLength)
|
||||
{
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
int32_t i = 0;
|
||||
variableNames.setValueDeleter(uhash_deleteUnicodeString);
|
||||
int32_t pos = -1;
|
||||
const UHashElement *e;
|
||||
while ((e = other.variableNames.nextElement(pos)) != 0) {
|
||||
UnicodeString* value =
|
||||
new UnicodeString(*(const UnicodeString*)e->value.pointer);
|
||||
// Exit out if value could not be created.
|
||||
if (value == NULL) {
|
||||
return;
|
||||
}
|
||||
variableNames.put(*(UnicodeString*)e->key.pointer, value, status);
|
||||
}
|
||||
|
||||
@ -57,10 +62,23 @@ TransliterationRuleData::TransliterationRuleData(const TransliterationRuleData&
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return;
|
||||
}
|
||||
for (int32_t i=0; i<variablesLength; ++i) {
|
||||
for (i=0; i<variablesLength; ++i) {
|
||||
variables[i] = other.variables[i]->clone();
|
||||
if (variables[i] == NULL) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Remove the array and exit if memory allocation error occured.
|
||||
if (status == U_MEMORY_ALLOCATION_ERROR) {
|
||||
for (int32_t n = i-1; n >= 0; n++) {
|
||||
delete variables[n];
|
||||
}
|
||||
uprv_free(variables);
|
||||
variables = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
// Do this last, _after_ setting up variables[].
|
||||
ruleSet.setData(this); // ruleSet must already be frozen
|
||||
|
Loading…
Reference in New Issue
Block a user