From 5c1720e12ab72e2f7b1f5e086e2ea25669418f01 Mon Sep 17 00:00:00 2001 From: Vladimir Weinstein Date: Thu, 18 Jul 2002 17:03:57 +0000 Subject: [PATCH] ICU-1948 code tried to access array as if it was a table. WRONG! Fixed! X-SVN-Rev: 9248 --- icu4c/source/common/uresdata.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/icu4c/source/common/uresdata.c b/icu4c/source/common/uresdata.c index 1cb2098836f..b2624dfa51a 100644 --- a/icu4c/source/common/uresdata.c +++ b/icu4c/source/common/uresdata.c @@ -346,19 +346,22 @@ res_findResource(const ResourceData *pResData, Resource r, const char** path) { *path += keyLen; } + /* if the resource is a table */ /* try the key based access */ - t2 = _res_findTableItemN(pResData->pRoot, t1, pathP, keyLen); - 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(closeIndex != pathP) { - if(type == RES_TABLE) { + if(type == RES_TABLE) { + t2 = _res_findTableItemN(pResData->pRoot, t1, pathP, keyLen); + 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(closeIndex != pathP) { /* if we indeed have an index, try to get the item by index */ t2 = _res_getTableItem(pResData->pRoot, t1, (uint16_t)indexR); - } else { /* if(type == RES_ARRAY) { */ - t2 = _res_getArrayItem(pResData->pRoot, t1, indexR); - } + } } + } else if(type == RES_ARRAY) { + t2 = _res_getArrayItem(pResData->pRoot, t1, indexR); + } else { /* can't do much here, except setting t2 to bogus */ + t2 = RES_BOGUS; } t1 = t2; type = RES_GET_TYPE(t1);