Fix crash in GameSave::serialiseOPS

Only particlesCount particles have been copied from the Simulation.
All the rest are uninitialised, and may have coordinates outside the
game area. Using those uninitialised coordinates in the index for
partsPosFirstMap may cause a crash.
This commit is contained in:
jacksonmj 2012-12-16 22:56:03 +00:00
parent d29c77b2d5
commit 9c6f3c7fbb

View File

@ -1701,7 +1701,7 @@ char * GameSave::serialiseOPS(int & dataLength)
partsPosLastMap = (unsigned int *)calloc(fullW*fullH, sizeof(unsigned));
partsPosCount = (unsigned int *)calloc(fullW*fullH, sizeof(unsigned));
partsPosLink = (unsigned int *)calloc(NPART, sizeof(unsigned));
for(i = 0; i < NPART; i++)
for(i = 0; i < particlesCount; i++)
{
if(particles[i].type)
{