summaryrefslogtreecommitdiff
path: root/src/client/GameSave.cpp
diff options
context:
space:
mode:
authorjacksonmj <mj-pt@jacksonmj.co.uk>2012-12-16 22:56:03 (GMT)
committer jacksonmj <mj-pt@jacksonmj.co.uk>2012-12-16 23:01:04 (GMT)
commit9c6f3c7fbb45d458169769b48154277e9e49ff60 (patch)
tree079ab021eefe841cd07aff2ab512c47a367cfa39 /src/client/GameSave.cpp
parentd29c77b2d5d9a03f64d35b7ef8727c7624e9cc99 (diff)
downloadpowder-9c6f3c7fbb45d458169769b48154277e9e49ff60.zip
powder-9c6f3c7fbb45d458169769b48154277e9e49ff60.tar.gz
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.
Diffstat (limited to 'src/client/GameSave.cpp')
-rw-r--r--src/client/GameSave.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/client/GameSave.cpp b/src/client/GameSave.cpp
index fbb9829..8da60c8 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)
{