From: Jason H Stover Date: Fri, 22 Jan 2010 21:48:04 +0000 (-0500) Subject: Set categoricals to NULL in one-pass covariance; avoid freeing NULL in categoricals_d... X-Git-Tag: fc11-i386-build81^0 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=34bf67fbfdce409a1cefdc101518c633636c1f43;p=pspp-builds.git Set categoricals to NULL in one-pass covariance; avoid freeing NULL in categoricals_destroy --- diff --git a/src/math/categoricals.c b/src/math/categoricals.c index 6002d8c1..33e3b51c 100644 --- a/src/math/categoricals.c +++ b/src/math/categoricals.c @@ -91,11 +91,14 @@ void categoricals_destroy ( struct categoricals *cat) { int i; - for (i = 0 ; i < cat->n_vp; ++i) - hmap_destroy (&cat->vp[i].map); - - pool_destroy (cat->pool); - free (cat); + if (cat != NULL) + { + for (i = 0 ; i < cat->n_vp; ++i) + hmap_destroy (&cat->vp[i].map); + + pool_destroy (cat->pool); + free (cat); + } } diff --git a/src/math/covariance.c b/src/math/covariance.c index d60d609e..1b5a2385 100644 --- a/src/math/covariance.c +++ b/src/math/covariance.c @@ -157,6 +157,7 @@ covariance_1pass_create (size_t n_vars, const struct variable **vars, cov->n_cm = (n_vars * (n_vars - 1) ) / 2; cov->cm = xcalloc (sizeof *cov->cm, cov->n_cm); + cov->categoricals = NULL; return cov; }