Subject: bug#9273: 23.3; malloc initialization should (sometimes) happen at runtime

From: Eli Zaretskii <[email-masked]>
Date: Sat, 13 Aug 2011 17:41:45 +0300

> Date: Sat, 13 Aug 2011 09:48:52 -0400
> From: Ken Brown <[email-masked]>
> CC: "[email-masked]" <[email-masked]>
> 
> _heapinfo is indeed consistent with the current heap.  But the pointer 
> that was passed to realloc points into the old heap.  So applying BLOCK 
> to that pointer yields an absurd result.  I can easily catch such cases 
> by testing for ptr < _heapbase, as in my patch to _free_internal_nolock, 
> but I have to figure out the best way to handle them once I've caught 
> them.

malloc a buffer, then copy the contents of the old one to the new
one.  You will have to know the size of the old block, which means you
will have to access the old copy of _heapinfo.