From 9c6f3c7fbb45d458169769b48154277e9e49ff60 Mon Sep 17 00:00:00 2001 From: jacksonmj Date: Sun, 16 Dec 2012 22:56:03 +0000 Subject: [PATCH] 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. --- src/client/GameSave.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/GameSave.cpp b/src/client/GameSave.cpp index fbb982951..8da60c863 100644 --- a/src/client/GameSave.cpp +++ b/src/client/GameSave.cpp @@ -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) {