From: Nicholas Clark Date: Fri, 10 Feb 2006 14:25:33 +0000 (+0000) Subject: With PERL_POISON defined, ensure freshly malloc()ed memory isn't zeros, X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=9a083ecf3183b31c0b60e9c5dac947cd40829810;p=p5sagit%2Fp5-mst-13.2.git With PERL_POISON defined, ensure freshly malloc()ed memory isn't zeros, and when PERL_TRACK_MEMPOOL is also defined scribble on any extension added by realloc(). p4raw-id: //depot/perl@27151 --- diff --git a/util.c b/util.c index c10dd29..61d4036 100644 --- a/util.c +++ b/util.c @@ -96,7 +96,13 @@ Perl_safesysmalloc(MEM_SIZE size) #ifdef PERL_TRACK_MEMPOOL struct perl_memory_debug_header *const header = (struct perl_memory_debug_header *)ptr; +#endif + +#ifdef PERL_POISON + Poison(((char *)ptr), size, char); +#endif +#ifdef PERL_TRACK_MEMPOOL header->interpreter = aTHX; /* Link us into the list. */ header->prev = &PL_memory_debug_header; @@ -180,6 +186,14 @@ Perl_safesysrealloc(Malloc_t where,MEM_SIZE size) struct perl_memory_debug_header *const header = (struct perl_memory_debug_header *)ptr; +# ifdef PERL_POISON + if (header->size < size) { + const MEM_SIZE fresh = size - header->size; + char *start_of_fresh = ((char *)ptr) + size; + Poison(start_of_fresh, fresh, char); + } +# endif + header->next->prev = header; header->prev->next = header;