Fix bug #21108.
authorBen Pfaff <blp@gnu.org>
Thu, 20 Sep 2007 04:48:13 +0000 (04:48 +0000)
committerBen Pfaff <blp@gnu.org>
Thu, 20 Sep 2007 04:48:13 +0000 (04:48 +0000)
* aggregate.c (cmd_aggregate): Destroy casereader consistently,
even if casereader fails.

* examine.q (run_examine): Ditto.

* glm.q (run_glm): Ditto.

* oneway.q (run_oneway): Ditto.

* regression.q (run_regression): Ditto.

* t-test.q (calculate): Ditto.

* descriptives.c (calc_descriptives): Ditto.  Also avoid
gratuitous casereader_clone.

src/language/stats/ChangeLog
src/language/stats/aggregate.c
src/language/stats/descriptives.c
src/language/stats/examine.q
src/language/stats/glm.q
src/language/stats/oneway.q
src/language/stats/regression.q
src/language/stats/t-test.q

index a36249a9fd9dc4b5c66718fb0ec6c37e077a5957..4f63f1676e7006dbb1fc9dc0d0ed5f8f52357d1e 100644 (file)
@@ -1,3 +1,23 @@
+2007-09-19  Ben Pfaff  <blp@gnu.org>
+
+       Fix bug #21108.
+       
+       * aggregate.c (cmd_aggregate): Destroy casereader consistently,
+       even if casereader fails.
+
+       * examine.q (run_examine): Ditto.
+        
+       * glm.q (run_glm): Ditto.
+
+       * oneway.q (run_oneway): Ditto.
+
+       * regression.q (run_regression): Ditto.
+
+       * t-test.q (calculate): Ditto.
+
+       * descriptives.c (calc_descriptives): Ditto.  Also avoid
+       gratuitous casereader_clone.
+
 2007-09-13  Jason Stover  <jhs@debs.hoobahooba.net>
 
        * regression.q (cmd_regression): Move declaration of models in to
index a9e1e4a4284932639938a75e9058582d615616ea..921c8ed0985ac28fda71f5f96b5754d226a7e618 100644 (file)
@@ -291,7 +291,10 @@ cmd_aggregate (struct lexer *lexer, struct dataset *ds)
       struct ccase c;
 
       if (!casereader_peek (group, 0, &c))
-        continue;
+        {
+          casereader_destroy (group);
+          continue;
+        }
       initialize_aggregate_info (&agr, &c);
       case_destroy (&c);
 
index 3fd23c8f289217de552f7d6ffe543d838e71e205..0b0d25bd23ce92c80e50efd3e83cc2fac5419810 100644 (file)
@@ -699,16 +699,18 @@ calc_descriptives (struct dsc_proc *dsc, struct casereader *group,
   size_t i;
 
   if (!casereader_peek (group, 0, &c))
-    return;
+    {
+      casereader_destroy (group);
+      return;
+    }
   output_split_file_values (ds, &c);
   case_destroy (&c);
 
   group = casereader_create_filter_weight (group, dataset_dict (ds),
                                            NULL, NULL);
 
-  casereader_split (group, &pass1, &pass2);
-  if (dsc->max_moment <= MOMENT_MEAN)
-    casereader_destroy (pass2);
+  pass1 = group;
+  pass2 = dsc->max_moment <= MOMENT_MEAN ? NULL : casereader_clone (pass1);
 
   for (i = 0; i < dsc->var_cnt; i++)
     {
@@ -758,7 +760,10 @@ calc_descriptives (struct dsc_proc *dsc, struct casereader *group,
         }
     }
   if (!casereader_destroy (pass1))
-    return;
+    {
+      casereader_destroy (pass2);
+      return;
+    }
 
   /* Second pass for higher-order moments. */
   if (dsc->max_moment > MOMENT_MEAN)
index d9b9bece6fbc79dca18519859325beae4332052b..4ad0230375c8e78fcf97f22c0c4de71f32630eb0 100644 (file)
@@ -720,7 +720,10 @@ run_examine (struct cmd_examine *cmd, struct casereader *input,
   struct factor *fctr;
 
   if (!casereader_peek (input, 0, &c))
-    return;
+    {
+      casereader_destroy (input);
+      return;
+    }
   output_split_file_values (ds, &c);
   case_destroy (&c);
 
index b121126545763c74439441e2d7183fb931cdcf92..e7620a30b4ac2f2377d12af0772ba6b13e491a94 100644 (file)
@@ -251,7 +251,10 @@ run_glm (struct casereader *input,
   assert (model != NULL);
 
   if (!casereader_peek (input, 0, &c))
-    return true;
+    {
+      casereader_destroy (input);
+      return true;
+    }
   output_split_file_values (ds, &c);
   case_destroy (&c);
 
index 2ca7809b526c9eae9e5b87556e54c5c86ce3dadb..f33a990edf06797ec401fa94116eeaf696f37de4 100644 (file)
@@ -899,7 +899,10 @@ run_oneway (struct cmd_oneway *cmd,
   struct ccase c;
 
   if (!casereader_peek (input, 0, &c))
-    return;
+    {
+      casereader_destroy (input);
+      return;
+    }
   output_split_file_values (ds, &c);
   case_destroy (&c);
 
index c10cc59e1f75409cea4bdd54153133024c0e1ff8..0b7250cee58b17361f34a58089ed2b2ad972542a 100644 (file)
@@ -1136,7 +1136,10 @@ run_regression (struct casereader *input, struct cmd_regression *cmd,
   assert (models != NULL);
 
   if (!casereader_peek (input, 0, &c))
-    return true;
+    {
+      casereader_destroy (input);
+      return true;
+    }
   output_split_file_values (ds, &c);
   case_destroy (&c);
 
index a1665d53adc800b1092c23d5894e4d01112eb242..db57c49999afb70d373441856737f0f5c3cdb225 100644 (file)
@@ -1787,7 +1787,10 @@ calculate(struct cmd_t_test *cmd,
   enum mv_class exclude = cmd->miss != TTS_INCLUDE ? MV_ANY : MV_SYSTEM;
 
   if (!casereader_peek (input, 0, &c))
-    return;
+    {
+      casereader_destroy (input);
+      return;
+    }
   output_split_file_values (ds, &c);
   case_destroy (&c);