mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-18 11:14:22 +00:00
ICU-3549 handle resultLength ptr == NULL
X-SVN-Rev: 15038
This commit is contained in:
parent
d1147ce4fe
commit
fa27757571
2 changed files with 19 additions and 16 deletions
|
@ -87,24 +87,25 @@ uenum_unextDefault(UEnumeration* en,
|
|||
int32_t* resultLength,
|
||||
UErrorCode* status)
|
||||
{
|
||||
UChar *ustr = NULL;
|
||||
int32_t len = 0;
|
||||
if (en->next != NULL) {
|
||||
UChar *tempUCharVal;
|
||||
const char *tempCharVal = en->next(en, resultLength, status);
|
||||
if (tempCharVal == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
tempUCharVal = (UChar*)
|
||||
_getBuffer(en, (*resultLength+1) * sizeof(UChar));
|
||||
if (!tempUCharVal) {
|
||||
*status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return NULL;
|
||||
const char *cstr = en->next(en, &len, status);
|
||||
if (cstr != NULL) {
|
||||
ustr = (UChar*) _getBuffer(en, (len+1) * sizeof(UChar));
|
||||
if (ustr == NULL) {
|
||||
*status = U_MEMORY_ALLOCATION_ERROR;
|
||||
} else {
|
||||
u_charsToUChars(cstr, ustr, len+1);
|
||||
}
|
||||
}
|
||||
u_charsToUChars(tempCharVal, tempUCharVal, *resultLength + 1);
|
||||
return tempUCharVal;
|
||||
} else {
|
||||
*status = U_UNSUPPORTED_ERROR;
|
||||
return NULL;
|
||||
}
|
||||
if (resultLength) {
|
||||
*resultLength = len;
|
||||
}
|
||||
return ustr;
|
||||
}
|
||||
|
||||
/* Don't call this directly. Only uenum_next should be calling this. */
|
||||
|
|
|
@ -1938,11 +1938,13 @@ ures_loc_nextLocale(UEnumeration* en,
|
|||
UResourceBundle *res = &(ctx->installed);
|
||||
UResourceBundle *k = NULL;
|
||||
const char *result = NULL;
|
||||
int32_t len = 0;
|
||||
if(ures_hasNext(res) && (k = ures_getNextResource(res, &ctx->curr, status))) {
|
||||
result = ures_getKey(k);
|
||||
*resultLength = uprv_strlen(result);
|
||||
} else {
|
||||
*resultLength = 0;
|
||||
len = uprv_strlen(result);
|
||||
}
|
||||
if (resultLength) {
|
||||
*resuleLength = len;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue