As noted under undefined behavior 179 in Annex J of the C Standard [ISO/IEC 9899:2011], the behavior of a program is undefined when
the The pointer argument to the
free
orrealloc
function does not match a pointer earlier returned by a memory management function, or the space has been deallocated by a call tofree
orrealloc
.
...