Fix memory leak in LOGISTIC command
authorJohn Darrington <john@darrington.wattle.id.au>
Sat, 25 May 2013 18:53:31 +0000 (20:53 +0200)
committerJohn Darrington <john@darrington.wattle.id.au>
Sun, 26 May 2013 04:41:34 +0000 (06:41 +0200)
src/language/stats/logistic.c

index 2c214516b711dc05d79e2bff025053871a1e1c0e..9a9e4e91bfc385dc8acf5361c27a8cef25c2490d 100644 (file)
@@ -741,6 +741,7 @@ lookup_variable (const struct hmap *map, const struct variable *var, unsigned in
 int
 cmd_logistic (struct lexer *lexer, struct dataset *ds)
 {
+  int i;
   /* Temporary location for the predictor variables.
      These may or may not include the categorical predictors */
   const struct variable **pred_vars;
@@ -1092,6 +1093,10 @@ cmd_logistic (struct lexer *lexer, struct dataset *ds)
     ok = proc_commit (ds) && ok;
   }
 
+  for (i = 0 ; i < lr.n_cat_predictors; ++i)
+    {
+      interaction_destroy (lr.cat_predictors[i]);
+    }
   free (lr.predictor_vars);
   free (lr.cat_predictors);
   free (lr.indep_vars);
@@ -1100,6 +1105,10 @@ cmd_logistic (struct lexer *lexer, struct dataset *ds)
 
  error:
 
+  for (i = 0 ; i < lr.n_cat_predictors; ++i)
+    {
+      interaction_destroy (lr.cat_predictors[i]);
+    }
   free (lr.predictor_vars);
   free (lr.cat_predictors);
   free (lr.indep_vars);