From: John Darrington Date: Wed, 28 Sep 2011 17:55:45 +0000 (+0200) Subject: Fixed a crash in REGRESSION when there were no non-missing values. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fbuilds%2F20111001030502%2Fpspp;p=pspp Fixed a crash in REGRESSION when there were no non-missing values. --- diff --git a/src/language/stats/regression.q b/src/language/stats/regression.q index c41f9e7895..4ef12c9847 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 0ea3efc8a2..81bbce436a 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