mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-06 14:05:32 +00:00
ICU-21174 Add a memory allocation check in MeasureUnit.
This commit is contained in:
parent
8bd1f49ab6
commit
abdf0e667d
1 changed files with 4 additions and 0 deletions
|
@ -861,6 +861,10 @@ LocalArray<MeasureUnit> MeasureUnit::splitToSingleUnits(int32_t& outCount, UErro
|
|||
const MeasureUnitImpl& impl = MeasureUnitImpl::forMeasureUnit(*this, temp, status);
|
||||
outCount = impl.units.length();
|
||||
MeasureUnit* arr = new MeasureUnit[outCount];
|
||||
if (arr == nullptr) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return LocalArray<MeasureUnit>();
|
||||
}
|
||||
for (int32_t i = 0; i < outCount; i++) {
|
||||
arr[i] = impl.units[i]->build(status);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue