Set categoricals to NULL in one-pass covariance; avoid freeing NULL in categoricals_d... fc11-i386-build81 fc11-x64-build78 sid-i386-build148
authorJason H Stover <jhs@math.gcsu.edu>
Fri, 22 Jan 2010 21:48:04 +0000 (16:48 -0500)
committerJason H Stover <jhs@math.gcsu.edu>
Fri, 22 Jan 2010 21:48:04 +0000 (16:48 -0500)
src/math/categoricals.c
src/math/covariance.c

index 6002d8c179aa09529fa7740a676ab7329f2255fa..33e3b51c62f99cc2290ce7918dbba6aedb111878 100644 (file)
@@ -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);
+    }
 }
 
 
index d60d609e45681ffc7858abb83490b0b07b09fb46..1b5a238558ac773fa30b7016bc83bf521b406e1c 100644 (file)
@@ -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;
 }