summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjacksonmj <mj-pt@jacksonmj.co.uk>2011-02-15 22:20:15 (GMT)
committer jacksonmj <mj-pt@jacksonmj.co.uk>2011-02-15 22:24:29 (GMT)
commit7ef2363f90242f8b3b8eb13df1ce68ada8fe63ee (patch)
tree7c5479762dcfbf6826286a92fe845a54af3ceb2b /src
parentd5fcee7a1ee8bdce2ea2930f803d5e4256b3b7e6 (diff)
downloadpowder-7ef2363f90242f8b3b8eb13df1ce68ada8fe63ee.zip
powder-7ef2363f90242f8b3b8eb13df1ce68ada8fe63ee.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)