Calculating a covariance matrix on a single variable crashed under Windows.
This change fixes that. It also prevents GUI users from attempting to
perform a correlation with only one variable, since if they are trying to
do that, then the have probably made a mistake.
const struct variable *weight, enum mv_class exclude)
{
size_t i;
- struct covariance *cov = xmalloc (sizeof *cov);
+ struct covariance *cov = xzalloc (sizeof *cov);
cov->passes = 1;
cov->state = 0;
cov->n_cm = (n_vars * (n_vars - 1) ) / 2;
- cov->cm = xcalloc (sizeof *cov->cm, cov->n_cm);
+ if (cov->n_cm > 0)
+ cov->cm = xcalloc (sizeof *cov->cm, cov->n_cm);
cov->categoricals = NULL;
return cov;
GtkTreeModel *liststore =
gtk_tree_view_get_model (GTK_TREE_VIEW (corr->variables));
- if (gtk_tree_model_iter_n_children (liststore, NULL) >= 1)
+ if (gtk_tree_model_iter_n_children (liststore, NULL) > 1)
return TRUE;
return FALSE;