From: Timo Sirainen Date: Tue, 22 Dec 2009 19:19:15 +0000 (-0500) Subject: DEBUG: i_free() now clears the memory before freeing it. X-Git-Tag: 2.0.beta2~97 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=478858aa9ca65a7a1b0bc028793d85b9591956a4;p=thirdparty%2Fdovecot%2Fcore.git DEBUG: i_free() now clears the memory before freeing it. --HG-- branch : HEAD --- diff --git a/src/lib/mempool-system.c b/src/lib/mempool-system.c index ba6a29ad12..ca74b26511 100644 --- a/src/lib/mempool-system.c +++ b/src/lib/mempool-system.c @@ -3,6 +3,7 @@ /* @UNSAFE: whole file */ #include "lib.h" +#include "safe-memset.h" #include "mempool.h" #include @@ -20,6 +21,8 @@ # include #endif +#define CLEAR_CHR 0xde + static const char *pool_system_get_name(pool_t pool); static void pool_system_ref(pool_t pool); static void pool_system_unref(pool_t *pool); @@ -89,6 +92,9 @@ static void *pool_system_malloc(pool_t pool ATTR_UNUSED, size_t size) static void pool_system_free(pool_t pool ATTR_UNUSED, void *mem ATTR_UNUSED) { +#if !defined(USE_GC) && defined(HAVE_MALLOC_USABLE_SIZE) && defined(DEBUG) + safe_memset(mem, CLEAR_CHR, malloc_usable_size(mem)); +#endif #ifndef USE_GC free(mem); #endif