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-Tag: v0.7.9~135 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=aa9247b3c3dfea8b1127d739b486c2e5bb8e54ce;p=pspp-builds.git 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 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