b = get_payload_block(a, ptr);
-# ifdef DEBUG_MALLOC
- vg_assert(blockSane(a, b));
-# endif
+ /* If this is one of V's areas, check carefully the block we're
+ getting back. This picks up simple block-end overruns. */
+ if (aid != VG_AR_CLIENT)
+ vg_assert(blockSane(a, b));
b_bszB = get_bszB(b);
b_pszB = bszB_to_pszB(a, b_bszB);
a->bytes_on_loan -= b_pszB;
+ /* If this is one of V's areas, fill it up with junk to enhance the
+ chances of catching any later reads of it. Note, 0xDD is
+ carefully chosen junk :-), in that: (1) 0xDDDDDDDD is an invalid
+ and non-word-aligned address on most systems, and (2) 0xDD is a
+ value which is unlikely to be generated by the new compressed
+ Vbits representation for memcheck. */
+ if (aid != VG_AR_CLIENT)
+ VG_(memset)(ptr, 0xDD, (SizeT)b_pszB);
+
// Put this chunk back on a list somewhere.
b_listno = pszB_to_listNo(b_pszB);
mkFreeBlock( a, b, b_bszB, b_listno );