ICU-21994 Fix heap-buffer-overflow

This commit is contained in:
Frank Tang 2022-04-15 11:47:25 -07:00 committed by Frank Yung-Fong Tang
parent 47824c5568
commit fca6b342c0

View file

@ -716,20 +716,19 @@ AliasDataBuilder::readAlias(
status = U_MEMORY_ALLOCATION_ERROR;
return;
}
int i = 0;
while (ures_hasNext(alias)) {
for (int i = 0; U_SUCCESS(status) && ures_hasNext(alias); i++) {
LocalUResourceBundlePointer res(
ures_getNextResource(alias, nullptr, &status));
const char* aliasFrom = ures_getKey(res.getAlias());
UnicodeString aliasTo =
ures_getUnicodeStringByKey(res.getAlias(), "replacement", &status);
if (U_FAILURE(status)) return;
checkType(aliasFrom);
checkReplacement(aliasTo);
rawTypes[i] = aliasFrom;
rawIndexes[i] = strings->add(aliasTo, status);
i++;
}
}