mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-08 06:53:45 +00:00
ICU-5426 Fix last check-in. Handle the case when malloc fails.
X-SVN-Rev: 20478
This commit is contained in:
parent
1c37b55ae0
commit
31120cdfc4
1 changed files with 9 additions and 4 deletions
|
@ -1852,10 +1852,15 @@ void UnicodeSet::releasePattern() {
|
|||
*/
|
||||
void UnicodeSet::setPattern(const UnicodeString& newPat) {
|
||||
releasePattern();
|
||||
patLen = newPat.length();
|
||||
pat = (UChar *)uprv_malloc((patLen + 1) * sizeof(UChar));
|
||||
newPat.extractBetween(0, patLen, pat);
|
||||
pat[patLen] = 0;
|
||||
int32_t newPatLen = newPat.length();
|
||||
pat = (UChar *)uprv_malloc((newPatLen + 1) * sizeof(UChar));
|
||||
if (pat) {
|
||||
patLen = newPatLen;
|
||||
newPat.extractBetween(0, patLen, pat);
|
||||
pat[patLen] = 0;
|
||||
}
|
||||
// else we don't care if malloc failed. This was just a nice cache.
|
||||
// We can regenerate an equivalent pattern later when requested.
|
||||
}
|
||||
|
||||
U_NAMESPACE_END
|
||||
|
|
Loading…
Add table
Reference in a new issue