Fixed crash with GLM and MEANS vs. SPLIT
authorJohn Darrington <john@darrington.wattle.id.au>
Wed, 24 Apr 2013 17:05:59 +0000 (19:05 +0200)
committerJohn Darrington <john@darrington.wattle.id.au>
Wed, 24 Apr 2013 17:05:59 +0000 (19:05 +0200)
Partial fix for bug #38820

src/language/stats/glm.c
src/language/stats/means.c
src/math/categoricals.c
src/math/categoricals.h
tests/language/dictionary/split-file.at

index 1ded71e9f1c6b69db56b6278a4ce8118bb6c5049..3d71779ff6e35ddacef4e3de5e6f66518d1ac48d 100644 (file)
@@ -324,6 +324,9 @@ cmd_glm (struct lexer *lexer, struct dataset *ds)
 
   const_var_set_destroy (factors);
   free (glm.factor_vars);
+  for (i = 0 ; i < glm.n_interactions; ++i)
+    interaction_destroy (glm.interactions[i]);
+
   free (glm.interactions);
   free (glm.dep_vars);
 
index 888a6a75836707f71564816ab6a15da2b8db8835..44a140ecb5fc0e589d3db81a4348260b7921300d 100644 (file)
@@ -1,5 +1,5 @@
 /* PSPP - a program for statistical analysis.
-   Copyright (C) 2011, 2012 Free Software Foundation, Inc.
+   Copyright (C) 2011, 2012, 2013 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -764,7 +764,7 @@ cmd_means (struct lexer *lexer, struct dataset *ds)
         const struct layer *lyr = &table->layers[l];
        const int n_vars = lyr->n_factor_vars;
         table->interactions[l] = interaction_create (NULL);
-        for (v = 0 ; v < n_vars ; ++v)
+        for (v = 0; v < n_vars ; ++v)
           {
             interaction_add_variable (table->interactions[l],
                                       lyr->factor_vars[v]);
@@ -786,12 +786,31 @@ cmd_means (struct lexer *lexer, struct dataset *ds)
     ok = proc_commit (ds) && ok;
   }
 
+  for (t = 0; t < means.n_tables; ++t)
+  {
+    int l;
+    struct mtable *table = &means.table[t];
+    for (l = 0; l < table->n_layers; ++l)
+      {
+       interaction_destroy (table->interactions[l]);
+      }
+  }
 
   pool_destroy (means.pool);
   return CMD_SUCCESS;
 
 error:
 
+  for (t = 0; t < means.n_tables; ++t)
+    {
+      int l;
+      struct mtable *table = &means.table[t];
+      for (l = 0; l < table->n_layers; ++l)
+       {
+         interaction_destroy (table->interactions[l]);
+       }
+    }
+  
   pool_destroy (means.pool);
   return CMD_FAILURE;
 }
index d0247f6d38a453cbbf7220e04f11f879a5140d65..d89dfdbb26b2c583513ff6d266ca4f2ac2e5a032 100644 (file)
@@ -103,7 +103,7 @@ lookup_variable (const struct hmap *map, const struct variable *var, unsigned in
       if (vn->var == var)
        break;
       
-      fprintf (stderr, "Warning: Hash table collision\n");
+      fprintf (stderr, "%s:%d Warning: Hash table collision\n", __FILE__, __LINE__);
     }
   
   return vn;
@@ -115,7 +115,7 @@ struct interact_params
   /* A map of cases indexed by a interaction_value */
   struct hmap ivmap;
 
-  struct interaction *iact;
+  const struct interaction *iact;
 
   int base_subscript_short;
   int base_subscript_long;
@@ -270,6 +270,7 @@ categoricals_destroy (struct categoricals *cat)
   int i;
   if (NULL == cat)
     return;
+
   for (i = 0; i < cat->n_iap; ++i)
     {
       struct interaction_value *iv = NULL;
@@ -284,7 +285,6 @@ categoricals_destroy (struct categoricals *cat)
       free (cat->iap[i].enc_sum);
       free (cat->iap[i].df_prod);
       hmap_destroy (&cat->iap[i].ivmap);
-      interaction_destroy (cat->iap[i].iact);
     }
 
   /* Interate over each variable and delete its value map */
index 450a202487713f1ee51e4898893303b8c981fabe..c5919bc455e883e131bb2aa637b1165d0bf36ea2 100644 (file)
@@ -28,7 +28,7 @@ struct interaction;
 
 union value ;
 
-struct categoricals *categoricals_create (struct interaction *const *, size_t n_int,
+struct categoricals *categoricals_create (struct interaction *const*, size_t n_int,
                                          const struct variable *wv, enum mv_class dep_excl,
                                          enum mv_class fctr_excl);
 
index 91bf92f436ead9a7ef102dbd04e9c954e2201859..710907ccec80c06e450cf6737c33a3ba776cf753 100644 (file)
@@ -90,10 +90,10 @@ EXPORT outfile='xxx'.
 FACTOR /VARIABLES = b c d.
 FILTER BY c.
 FREQUENCIES b.
-GLM c BY b.
+GLM c BY b.
 LIST.
 LOGISTIC REGRESSION q WITH b.
-MEANS c b.
+MEANS c b.
 NPAR TESTS /MCNEMAR q.
 ONEWAY c BY b.
 QUICK CLUSTER b c.