]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
DEBUG: i_free() now clears the memory before freeing it.
authorTimo Sirainen <tss@iki.fi>
Tue, 22 Dec 2009 19:19:15 +0000 (14:19 -0500)
committerTimo Sirainen <tss@iki.fi>
Tue, 22 Dec 2009 19:19:15 +0000 (14:19 -0500)
--HG--
branch : HEAD

src/lib/mempool-system.c

index ba6a29ad12828d3161d3b89a83263011a0f3d2b3..ca74b26511cf566550e2ea83291fb503cf65bbe8 100644 (file)
@@ -3,6 +3,7 @@
 /* @UNSAFE: whole file */
 
 #include "lib.h"
+#include "safe-memset.h"
 #include "mempool.h"
 
 #include <stdlib.h>
@@ -20,6 +21,8 @@
 #  include <gc.h>
 #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