From 7ef2363f90242f8b3b8eb13df1ce68ada8fe63ee Mon Sep 17 00:00:00 2001 From: jacksonmj Date: Tue, 15 Feb 2011 22:20:15 +0000 Subject: [PATCH] Crash when element with invalid type is created Generally due to an invalid ctype for clone. --- src/powder.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/powder.c b/src/powder.c index 77dc305cf..873935b29 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=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)