Fixed a crash in REGRESSION when there were no non-missing values. 20110929030503/pspp 20110930030502/pspp 20111001030502/pspp 20111002030502/pspp 20111003030502/pspp 20111004030502/pspp 20111005030502/pspp 20111006030503/pspp
authorJohn Darrington <john@darrington.wattle.id.au>
Wed, 28 Sep 2011 17:55:45 +0000 (19:55 +0200)
committerJohn Darrington <john@darrington.wattle.id.au>
Wed, 28 Sep 2011 17:55:45 +0000 (19:55 +0200)
src/language/stats/regression.q
tests/language/stats/regression.at

index c41f9e7895e7e05595331b767994a725cf417914..4ef12c98479ec2aac3b0711aaedef9a7410899c5 100644 (file)
@@ -792,6 +792,7 @@ identify_indep_vars (const struct variable **indep_vars,
     }
   return n_indep_vars;
 }
+
 static double
 fill_covariance (gsl_matrix *cov, struct covariance *all_cov, 
                 const struct variable **vars,
@@ -804,12 +805,15 @@ fill_covariance (gsl_matrix *cov, struct covariance *all_cov,
   size_t dep_subscript;
   size_t *rows;
   const gsl_matrix *ssizes;
-  gsl_matrix *cm;
   const gsl_matrix *mean_matrix;
   const gsl_matrix *ssize_matrix;
   double result = 0.0;
   
-  cm = covariance_calculate_unnormalized (all_cov);
+  gsl_matrix *cm = covariance_calculate_unnormalized (all_cov);
+
+  if ( cm == NULL)
+    return 0;
+
   rows = xnmalloc (cov->size1 - 1, sizeof (*rows));
   
   for (i = 0; i < n_all_vars; i++)
index 0ea3efc8a256aabf1bbe963e38d1d80cfa818d70..81bbce436a998bc737dea03b8e5d6017ab84500f 100644 (file)
@@ -1590,3 +1590,27 @@ Table: Coefficients
 ,,,,,,
 ])
 AT_CLEANUP
+
+AT_SETUP([REGRESSION no crash on all missing])
+AT_DATA([regcrash.sps], [dnl
+data list list /x * y.
+begin data.
+ . .
+ . .
+ . .
+ . .
+ . .
+ . .
+ . .
+ . .
+ . .
+ . .
+end data.
+
+
+regression /variables=x y /dependent=y.
+])
+
+AT_CHECK([pspp -o pspp.csv regcrash.sps], [1], [ignore], [ignore])
+
+AT_CLEANUP