diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2008-10-18 14:12:56 +0200 |
---|---|---|
committer | Jelmer Vernooij <jelmer@samba.org> | 2008-10-18 14:12:56 +0200 |
commit | fcce58cc61e4ed66de7d81064f40ff5a4e5b6346 (patch) | |
tree | bbf9d0917acffee32ce1f830301c9e02804691cf /lib/util/util.c | |
parent | 3189d141522d7d710fa8c7f58e92bffd854088ce (diff) | |
download | samba-fcce58cc61e4ed66de7d81064f40ff5a4e5b6346.tar.gz samba-fcce58cc61e4ed66de7d81064f40ff5a4e5b6346.tar.bz2 samba-fcce58cc61e4ed66de7d81064f40ff5a4e5b6346.zip |
Add extra argument free_on_fail to realloc_array() in Samba 4, as used by Samba 3.
Diffstat (limited to 'lib/util/util.c')
-rw-r--r-- | lib/util/util.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/util/util.c b/lib/util/util.c index 5fc785d642..4c5ae973a1 100644 --- a/lib/util/util.c +++ b/lib/util/util.c @@ -569,11 +569,13 @@ _PUBLIC_ bool all_zero(const uint8_t *ptr, size_t size) /** realloc an array, checking for integer overflow in the array size */ -_PUBLIC_ void *realloc_array(void *ptr, size_t el_size, unsigned count) +_PUBLIC_ void *realloc_array(void *ptr, size_t el_size, unsigned count, bool free_on_fail) { #define MAX_MALLOC_SIZE 0x7fffffff if (count == 0 || count >= MAX_MALLOC_SIZE/el_size) { + if (free_on_fail) + SAFE_FREE(ptr); return NULL; } if (!ptr) { @@ -588,7 +590,7 @@ _PUBLIC_ void *realloc_array(void *ptr, size_t el_size, unsigned count) void *malloc_array(size_t el_size, unsigned int count) { - return realloc_array(NULL, el_size, count); + return realloc_array(NULL, el_size, count, false); } _PUBLIC_ void *talloc_check_name_abort(const void *ptr, const char *name) |