projects
/
pspp
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix up potential overflows in size calculations by replacing
[pspp]
/
src
/
levene.c
diff --git
a/src/levene.c
b/src/levene.c
index 11e7480acfc115f436d6a81e6d7c336a933f5352..5de5220588564cb6674fd20aa04e21279dd3f0bf 100644
(file)
--- a/
src/levene.c
+++ b/
src/levene.c
@@
-16,8
+16,8
@@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 5
9 Temple Place - Suite 330
, Boston, MA
- 0211
1-1307
, USA. */
+ Foundation, Inc., 5
1 Franklin Street, Fifth Floor
, Boston, MA
+ 0211
0-1301
, USA. */
#include <config.h>
#include "levene.h"
#include <config.h>
#include "levene.h"
@@
-68,7
+68,7
@@
struct levene_info
struct variable *v_indep;
/* Number of dependent variables */
struct variable *v_indep;
/* Number of dependent variables */
-
in
t n_dep;
+
size_
t n_dep;
/* The dependent variables */
struct variable **v_dep;
/* The dependent variables */
struct variable **v_dep;
@@
-77,8
+77,7
@@
struct levene_info
enum lev_missing missing;
/* Function to test for missing values */
enum lev_missing missing;
/* Function to test for missing values */
- is_missing_func is_missing;
-
+ is_missing_func *is_missing;
};
/* First pass */
};
/* First pass */
@@
-95,7
+94,7
@@
static void levene2_postcalc (void *);
void
levene(const struct casefile *cf,
void
levene(const struct casefile *cf,
- struct variable *v_indep,
in
t n_dep, struct variable **v_dep,
+ struct variable *v_indep,
size_
t n_dep, struct variable **v_dep,
enum lev_missing missing, is_missing_func value_is_missing)
{
struct casereader *r;
enum lev_missing missing, is_missing_func value_is_missing)
{
struct casereader *r;
@@
-157,9
+156,9
@@
static struct lz_stats *lz;
static void
levene_precalc (const struct levene_info *l)
{
static void
levene_precalc (const struct levene_info *l)
{
-
in
t i;
+
size_
t i;
- lz
= xmalloc (sizeof (struct lz_stats ) * l->n_dep )
;
+ lz
= xnmalloc (l->n_dep, sizeof *lz)
;
for(i = 0; i < l->n_dep ; ++i )
{
for(i = 0; i < l->n_dep ; ++i )
{
@@
-187,7
+186,7
@@
levene_precalc (const struct levene_info *l)
static int
levene_calc (const struct ccase *c, void *_l)
{
static int
levene_calc (const struct ccase *c, void *_l)
{
-
in
t i;
+
size_
t i;
int warn = 0;
struct levene_info *l = (struct levene_info *) _l;
const union value *gv = case_data (c, l->v_indep->fv);
int warn = 0;
struct levene_info *l = (struct levene_info *) _l;
const union value *gv = case_data (c, l->v_indep->fv);
@@
-202,7
+201,7
@@
levene_calc (const struct ccase *c, void *_l)
struct variable *v = l->v_dep[i];
const union value *val = case_data (c, v->fv);
struct variable *v = l->v_dep[i];
const union value *val = case_data (c, v->fv);
- if (l->is_missing
(val,v
) )
+ if (l->is_missing
(&v->miss, val
) )
{
return 0;
}
{
return 0;
}
@@
-225,7
+224,7
@@
levene_calc (const struct ccase *c, void *_l)
if ( 0 == gs )
continue ;
if ( 0 == gs )
continue ;
- if ( ! l->is_missing(
v,var
))
+ if ( ! l->is_missing(
&var->miss, v
))
{
levene_z= fabs(v->f - gs->mean);
lz[i].grand_total += levene_z * weight;
{
levene_z= fabs(v->f - gs->mean);
lz[i].grand_total += levene_z * weight;
@@
-242,7
+241,7
@@
levene_calc (const struct ccase *c, void *_l)
static void
levene_postcalc (void *_l)
{
static void
levene_postcalc (void *_l)
{
-
in
t v;
+
size_
t v;
struct levene_info *l = (struct levene_info *) _l;
struct levene_info *l = (struct levene_info *) _l;
@@
-262,11
+261,11
@@
static double *lz_denominator;
static void
levene2_precalc (void *_l)
{
static void
levene2_precalc (void *_l)
{
-
in
t v;
+
size_
t v;
struct levene_info *l = (struct levene_info *) _l;
struct levene_info *l = (struct levene_info *) _l;
- lz_denominator =
(double *) xmalloc(sizeof(double) * l->n_dep
);
+ lz_denominator =
xnmalloc (l->n_dep, sizeof *lz_denominator
);
/* This stuff could go in the first post calc . . . */
for (v = 0; v < l->n_dep; ++v)
/* This stuff could go in the first post calc . . . */
for (v = 0; v < l->n_dep; ++v)
@@
-291,7
+290,7
@@
levene2_precalc (void *_l)
static int
levene2_calc (const struct ccase *c, void *_l)
{
static int
levene2_calc (const struct ccase *c, void *_l)
{
-
in
t i;
+
size_
t i;
int warn = 0;
struct levene_info *l = (struct levene_info *) _l;
int warn = 0;
struct levene_info *l = (struct levene_info *) _l;
@@
-309,7
+308,7
@@
levene2_calc (const struct ccase *c, void *_l)
struct variable *v = l->v_dep[i];
const union value *val = case_data (c, v->fv);
struct variable *v = l->v_dep[i];
const union value *val = case_data (c, v->fv);
- if (l->is_missing(
val,v
) )
+ if (l->is_missing(
&v->miss, val
) )
{
return 0;
}
{
return 0;
}
@@
-330,7
+329,7
@@
levene2_calc (const struct ccase *c, void *_l)
if ( 0 == gs )
continue;
if ( 0 == gs )
continue;
- if ( ! l->is_missing
(v,var
) )
+ if ( ! l->is_missing
(&var->miss, v
) )
{
levene_z = fabs(v->f - gs->mean);
lz_denominator[i] += weight * pow2(levene_z - gs->lz_mean);
{
levene_z = fabs(v->f - gs->mean);
lz_denominator[i] += weight * pow2(levene_z - gs->lz_mean);
@@
-344,7
+343,7
@@
levene2_calc (const struct ccase *c, void *_l)
static void
levene2_postcalc (void *_l)
{
static void
levene2_postcalc (void *_l)
{
-
in
t v;
+
size_
t v;
struct levene_info *l = (struct levene_info *) _l;
struct levene_info *l = (struct levene_info *) _l;