Poison freed memory objects
When compiled w/ -DCLIB_DEBUG=1, paint 0x13 across freed memory
blocks. Should result in a characteristic SIGSEGV if someone
dereferences a pointer in a freed vector element, etc.
@@ -4271,6 +4271,14 @@ void mspace_put (mspace msp, void *p_arg)
mheap_put_trace ((u64)p_arg, psize);
}
+#if CLIB_DEBUG > 0
+ /* Poison the object */
+ {
+ size_t psize = mspace_usable_size (object_header);
+ memset (object_header, 0x13, psize);
+ }
+#endif
+
/* And free it... */
mspace_free (msp, object_header);
}
