summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjacksonmj <mj-pt@jacksonmj.co.uk>2011-02-15 22:20:15 (GMT)
committer FacialTurd <simon@hardwired.org.uk>2011-02-18 23:06:22 (GMT)
commit81ce5d74cc2ccbeb462ea5af7d87e7f24b8bf0f1 (patch)
treec518116d873765d1260a96b7e770e03dcf77f2e3 /src
parent1b2330251395faef9f5b9f47094af205ed6acbbe (diff)
downloadpowder-81ce5d74cc2ccbeb462ea5af7d87e7f24b8bf0f1.zip
powder-81ce5d74cc2ccbeb462ea5af7d87e7f24b8bf0f1.tar.gz
Crash when element with invalid type is created
Generally due to an invalid ctype for clone.
Diffstat (limited to 'src')
-rw-r--r--src/powder.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/powder.c b/src/powder.c
index 77dc305..873935b 100644
--- a/src/powder.c
+++ b/src/powder.c
@@ -454,7 +454,7 @@ _inline void part_change_type(int i, int x, int y, int t)
inline void part_change_type(int i, int x, int y, int t)
#endif
{
- if (x<0 || y<0 || x>=XRES || y>=YRES || i>=NPART)
+ if (x<0 || y<0 || x>=XRES || y>=YRES || i>=NPART || t<0 || t>=PT_NUM)
return;
parts[i].type = t;
if (t==PT_PHOT)// || t==PT_NEUT)
@@ -485,7 +485,7 @@ inline int create_n_parts(int n, int x, int y, float vx, float vy, int t)
if (n>680) {
n = 680;
}
- if (x<0 || y<0 || x>=XRES || y>=YRES)
+ if (x<0 || y<0 || x>=XRES || y>=YRES || t<0 || t>=PT_NUM)
return -1;
for (c; c<n; c++) {
@@ -523,7 +523,7 @@ inline int create_part(int p, int x, int y, int t)
{
int i;
- if (x<0 || y<0 || x>=XRES || y>=YRES)
+ if (x<0 || y<0 || x>=XRES || y>=YRES || t<0 || t>=PT_NUM)
return -1;
if (t==SPC_HEAT||t==SPC_COOL)