Skip to content

Commit 44622e3

Browse files
committed
ICU-23112 Add check for avoid underflow in MeasureUnit::getIdentifier
1 parent 08a0746 commit 44622e3

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

icu4c/source/i18n/measunit.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2650,7 +2650,13 @@ const char *MeasureUnit::getSubtype() const {
26502650
}
26512651

26522652
const char *MeasureUnit::getIdentifier() const {
2653-
return fImpl ? fImpl->identifier.data() : gSubTypes[getOffset()];
2653+
if (fImpl){
2654+
return fImpl->identifier.data();
2655+
} else if (fTypeId < 0 || fSubTypeId < 0) {
2656+
return "";
2657+
} else {
2658+
return gSubTypes[getOffset()];
2659+
}
26542660
}
26552661

26562662
bool MeasureUnit::operator==(const UObject& other) const {

0 commit comments

Comments
 (0)