summaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2006-02-10 14:25:33 +0000
committerNicholas Clark <nick@ccl4.org>2006-02-10 14:25:33 +0000
commit9a083ecf3183b31c0b60e9c5dac947cd40829810 (patch)
tree6e4388d3879842d1d9d9591ccf2bcde322240b8e /util.c
parentbf38c51f361107f758fabf5590b0852bea1538f6 (diff)
downloadperl-9a083ecf3183b31c0b60e9c5dac947cd40829810.tar.gz
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
Diffstat (limited to 'util.c')
-rw-r--r--util.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/util.c b/util.c
index c10dd29e11..61d40365c1 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;