summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjacksonmj <mj-pt@jacksonmj.co.uk>2011-08-11 08:41:10 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2011-08-11 10:49:42 (GMT)
commit806e1933a2f1a80feeeb10e7923ae58461640225 (patch)
treee639b4c150ef7c77af1e4d148dc87a8ff9a32330 /src
parent3ed6a44a24f907fcbb5b696f6668feeae608bb12 (diff)
downloadpowder-806e1933a2f1a80feeeb10e7923ae58461640225.zip
powder-806e1933a2f1a80feeeb10e7923ae58461640225.tar.gz
Fix segfault when there are no unused particles before parts_lastActiveIndex
Diffstat (limited to 'src')
-rw-r--r--src/powder.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/powder.c b/src/powder.c
index 88cb713..095a6ed 100644
--- a/src/powder.c
+++ b/src/powder.c
@@ -2447,8 +2447,16 @@ void update_particles(pixel *vid)//doesn't update the particles themselves, but
lastPartUnused = i;
}
}
- if (parts_lastActiveIndex>=NPART-1) parts[lastPartUnused].life = -1;
- else parts[lastPartUnused].life = parts_lastActiveIndex+1;
+ if (lastPartUnused==-1)
+ {
+ if (parts_lastActiveIndex>=NPART-1) pfree = -1;
+ else pfree = parts_lastActiveIndex+1;
+ }
+ else
+ {
+ if (parts_lastActiveIndex>=NPART-1) parts[lastPartUnused].life = -1;
+ else parts[lastPartUnused].life = parts_lastActiveIndex+1;
+ }
parts_lastActiveIndex = lastPartUsed;
for (y=0; y<YRES/CELL; y++)
{