mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-15 01:42:37 +00:00
ICU-4703 Fix a memory leak on function failure
X-SVN-Rev: 19464
This commit is contained in:
parent
bc071af705
commit
27ec624563
1 changed files with 3 additions and 0 deletions
|
@ -283,6 +283,7 @@ static UDataMemory *udata_cacheDataItem(const char *path, UDataMemory *item, UEr
|
|||
}
|
||||
newElement->item = UDataMemory_createNewInstance(pErr);
|
||||
if (U_FAILURE(*pErr)) {
|
||||
uprv_free(newElement);
|
||||
return NULL;
|
||||
}
|
||||
UDatamemory_assign(newElement->item, item);
|
||||
|
@ -292,6 +293,8 @@ static UDataMemory *udata_cacheDataItem(const char *path, UDataMemory *item, UEr
|
|||
newElement->name = uprv_malloc(nameLen+1);
|
||||
if (newElement->name == NULL) {
|
||||
*pErr = U_MEMORY_ALLOCATION_ERROR;
|
||||
uprv_free(newElement->item);
|
||||
uprv_free(newElement);
|
||||
return NULL;
|
||||
}
|
||||
uprv_strcpy(newElement->name, baseName);
|
||||
|
|
Loading…
Add table
Reference in a new issue