From aa9247b3c3dfea8b1127d739b486c2e5bb8e54ce Mon Sep 17 00:00:00 2001 From: John Darrington Date: Wed, 28 Sep 2011 19:55:45 +0200 Subject: [PATCH] Fixed a crash in REGRESSION when there were no non-missing values. --- src/language/stats/regression.q | 8 ++++++-- tests/language/stats/regression.at | 24 ++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/src/language/stats/regression.q b/src/language/stats/regression.q index c41f9e78..4ef12c98 100644 --- a/src/language/stats/regression.q +++ b/src/language/stats/regression.q @@ -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++) diff --git a/tests/language/stats/regression.at b/tests/language/stats/regression.at index 0ea3efc8..81bbce43 100644 --- a/tests/language/stats/regression.at +++ b/tests/language/stats/regression.at @@ -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 -- 2.30.2