From 2e783a47076bd0994b6ce86df7ec967bc1c2da63 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sun, 12 Aug 2001 17:30:01 +0000 Subject: this is a big global fix for the ptr = Realloc(ptr, size) bug. many possible mem leaks, and segfaults fixed. someone should port this fix to 2.2 also. (This used to be commit fa8e55b8b465114ce209344965c1ca0333b84db9) --- source3/lib/util_array.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'source3/lib/util_array.c') diff --git a/source3/lib/util_array.c b/source3/lib/util_array.c index 567c170834..dcb08d9ce7 100644 --- a/source3/lib/util_array.c +++ b/source3/lib/util_array.c @@ -58,15 +58,18 @@ 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])); + tary = (void**)Realloc((*array), ((*len)+1)*sizeof((*array)[0])); - if ((*array) != NULL) + if (tary != NULL) { + (*array) = tary; (*array)[(*len)] = item; (*len)++; return item; -- cgit