From 4029c07550295659b391220324f348f4b1a86381 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sat, 23 Jun 2012 22:30:43 +0000 Subject: [PATCH] -LRN: Poisoning: Poisons memory before freeing it. It uses msize() CRT function, which (i believe) is not available on other platforms. This patch was intended to make the output of the next patch (see below) more apparent. --- src/util/common_allocation.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/util/common_allocation.c b/src/util/common_allocation.c index 5e1f75eb7..801eeeebc 100644 --- a/src/util/common_allocation.c +++ b/src/util/common_allocation.c @@ -197,6 +197,17 @@ GNUNET_xfree_ (void *ptr, const char *filename, int linenumber) #ifdef W32_MEM_LIMIT ptr = &((size_t *) ptr)[-1]; mem_used -= *((size_t *) ptr); +#endif +#if WINDOWS +#if ENABLE_POISONING + { + size_t i; + char baadfood[4] = "\xBA\xAD\xF0\x0D"; + size_t s = _msize (ptr); + for (i = 0; i < s; i++) + ((char *) ptr)[i] = baadfood[i % 4]; + } +#endif #endif free (ptr); } -- 2.25.1