I'm using the C99 standard as an example here, which may or may not be what you're using. It should apply, though. In the C99 standard, appendix J.2 lists undefined behavior. You'd want to note:
An object is referred to outside of its lifetime (6.2.4).
The value of a pointer to an object whose lifetime has ended is used (6.2.4).
mah alluded to this above - since the behavior is undefined, you don't know what will happen. In your case, the data is probably left behind and you're now improperly accessing free'd data which just so happens to still be accurate. Give it time and more malloc's and that data will likely/eventually change out from under you.
Edit: Link to the document for reference: http://www.open-std.org/jtc1/sc22/WG14/www/docs/n1256.pdf