summaryrefslogtreecommitdiffstats
path: root/source/lib/util_array.c
diff options
context:
space:
mode:
Diffstat (limited to 'source/lib/util_array.c')
-rw-r--r--source/lib/util_array.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/source/lib/util_array.c b/source/lib/util_array.c
index 567c170834a..dcb2a6b5f08 100644
--- a/source/lib/util_array.c
+++ b/source/lib/util_array.c
@@ -58,18 +58,20 @@ void* add_copy_to_array(uint32 *len, void ***array, const void *item,
void* add_item_to_array(uint32 *len, void ***array, void *item)
{
+ void **tary;
+
if (len == NULL || array == NULL)
- {
return NULL;
- }
- (*array) = (void**)Realloc((*array), ((*len)+1)*sizeof((*array)[0]));
-
- if ((*array) != NULL)
- {
+ tary = (void**)Realloc((*array), ((*len)+1)*sizeof((*array)[0]));
+
+ if (tary != NULL) {
+ (*array) = tary;
(*array)[(*len)] = item;
(*len)++;
return item;
+ } else {
+ free((char *)*array);
}
return NULL;
}