Fix memory overwrite bug in memory manager

Surprising this has been in the code this long.
This commit is contained in:
Scott Ludwig 2016-06-04 16:07:01 -07:00 committed by Nathan Fulton
parent 4874844ec2
commit 6a0c49d05e

View File

@ -1041,7 +1041,11 @@ void MemMgr::WriteHeader(Heap *pheap, MemHeader *pmhdrDst, MemHeader *pmhdrSrc,
memcpy(pmhdrDst, pmhdrSrc, cb);
}
#else
memcpy(pmhdrDst, pmhdrSrc, cb);
if (pmhdrSrc + cb <= pmhdrDst || pmhdrDst + cb <= pmhdrSrc) {
memcpy(pmhdrDst, pmhdrSrc, cb);
} else {
memmove(pmhdrDst, pmhdrSrc, cb);
}
#endif
}