ICU-21335 Disallowed looking up resources by index in table-based resources.
diff --git a/icu4c/source/common/uresdata.cpp b/icu4c/source/common/uresdata.cpp
index ae731e4..9af081b 100644
--- a/icu4c/source/common/uresdata.cpp
+++ b/icu4c/source/common/uresdata.cpp
@@ -960,14 +960,6 @@
if(URES_IS_TABLE(type)) {
*key = pathP;
t2 = res_getTableItemByKey(pResData, t1, &indexR, key);
- if(t2 == RES_BOGUS) {
- /* if we fail to get the resource by key, maybe we got an index */
- indexR = uprv_strtol(pathP, &closeIndex, 10);
- if(indexR >= 0 && *closeIndex == 0 && (*pathP != '0' || closeIndex - pathP == 1)) {
- /* if we indeed have an index, try to get the item by index */
- t2 = res_getTableItemByIndex(pResData, t1, indexR, key);
- } // else t2 is already RES_BOGUS
- }
} else if(URES_IS_ARRAY(type)) {
indexR = uprv_strtol(pathP, &closeIndex, 10);
if(indexR >= 0 && *closeIndex == 0) {
diff --git a/icu4c/source/test/cintltst/creststn.c b/icu4c/source/test/cintltst/creststn.c
index 8c9275f..ed044db 100644
--- a/icu4c/source/test/cintltst/creststn.c
+++ b/icu4c/source/test/cintltst/creststn.c
@@ -2319,16 +2319,12 @@
/* test indexed aliasing */
- tb = ures_getByKey(aliasB, "zoneTests", tb, &status);
- tb = ures_getByKey(tb, "zoneAlias2", tb, &status);
- string = tres_getString(tb, -1, NULL, &strLen, &status);
-
en = ures_findResource("/ICUDATA-zone/en/zoneStrings/3/0", en, &status);
- sequence = tres_getString(en, -1, NULL, &seqLen, &status);
- if(U_FAILURE(status) || seqLen != strLen || u_strncmp(sequence, string, seqLen) != 0) {
- log_err("Referencing alias didn't get the right string (5)\n");
+ if(status != U_MISSING_RESOURCE_ERROR) {
+ log_err("Index lookup in a table resource didn't get U_MISSING_RESOURCE_ERROR!\n");
}
+ status = U_ZERO_ERROR;
}
/* test getting aliased string by index */
{