From b9de3d570fdf999256220affaa35e2a24d34943c Mon Sep 17 00:00:00 2001 From: Ram Viswanadha Date: Fri, 17 Aug 2001 22:14:17 +0000 Subject: [PATCH] ICU-1090 fixed ures_getByKey crashing X-SVN-Rev: 5526 --- icu4c/source/common/uresdata.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/icu4c/source/common/uresdata.c b/icu4c/source/common/uresdata.c index 0c71679f12..013312c13e 100644 --- a/icu4c/source/common/uresdata.c +++ b/icu4c/source/common/uresdata.c @@ -121,6 +121,10 @@ _res_findTableIndex(const Resource *pRoot, const Resource res, const char *key) limit=*p++; /* number of entries */ + if(limit == 0) { /* this table is empty */ + return URESDATA_ITEM_NOT_FOUND; + } + /* do a binary search for the key */ start=0; while(startpRoot, pResData->rootRes, key); } -U_CFUNC Resource res_getArrayItem(const ResourceData *pResData, const Resource array, const int32_t indexR) { +U_CFUNC Resource +res_getArrayItem(const ResourceData *pResData, const Resource array, const int32_t indexR) { return _res_getArrayItem(pResData->pRoot, array, indexR); } -U_CFUNC Resource res_getTableItemByKey(const ResourceData *pResData, const Resource table, int32_t* indexR, const char* * key) { +U_CFUNC Resource +res_getTableItemByKey(const ResourceData *pResData, const Resource table, int32_t* indexR, const char* * key) { uint16_t tempIndex; if(key != NULL) { tempIndex = _res_findTableIndex(pResData->pRoot, table, *key); @@ -260,7 +266,8 @@ U_CFUNC Resource res_getTableItemByKey(const ResourceData *pResData, const Resou } } -U_CFUNC Resource res_getTableItemByIndex(const ResourceData *pResData, const Resource table, int32_t indexR, const char * * key) { +U_CFUNC Resource +res_getTableItemByIndex(const ResourceData *pResData, const Resource table, int32_t indexR, const char * * key) { if(indexR>-1) { if(key != NULL) { *key = _res_getTableKey(pResData->pRoot, table, (uint16_t)indexR); @@ -271,7 +278,8 @@ U_CFUNC Resource res_getTableItemByIndex(const ResourceData *pResData, const Res } } -U_CFUNC int32_t res_getTableSize(const ResourceData *pResData, Resource table) { +U_CFUNC int32_t +res_getTableSize(const ResourceData *pResData, Resource table) { uint16_t *p=(uint16_t *)RES_GET_POINTER(pResData->pRoot, table); return *p; }