Mercurial > dovecot > original-hg > dovecot-1.2
changeset 6300:7d82a232b5b0 HEAD
pool_system_realloc(): Moved malloc_usable_size() check before realloc() so
that we don't assert-crash if realloc() shrinks memory.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Thu, 16 Aug 2007 17:23:11 +0300 |
parents | 6342c8cc76c7 |
children | 8bca8efebfcf |
files | src/lib/mempool-system.c |
diffstat | 1 files changed, 5 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib/mempool-system.c Wed Aug 15 19:17:48 2007 +0300 +++ b/src/lib/mempool-system.c Thu Aug 16 17:23:11 2007 +0300 @@ -97,6 +97,11 @@ if (new_size == 0 || new_size > SSIZE_T_MAX) i_panic("Trying to allocate %"PRIuSIZE_T" bytes", new_size); +#if !defined(USE_GC) && defined(HAVE_MALLOC_USABLE_SIZE) + i_assert(old_size == (size_t)-1 || mem == NULL || + old_size <= malloc_usable_size(mem)); +#endif + #ifndef USE_GC mem = realloc(mem, new_size); #else @@ -107,10 +112,6 @@ "pool_system_realloc(): Out of memory"); } -#if !defined(USE_GC) && defined(HAVE_MALLOC_USABLE_SIZE) - i_assert(old_size == (size_t)-1 || mem == NULL || - old_size <= malloc_usable_size(mem)); -#endif if (old_size < new_size) { /* clear new data */ memset((char *) mem + old_size, 0, new_size - old_size);