From: Friedrich Beckmann Date: Mon, 17 Aug 2020 17:43:37 +0000 (+0200) Subject: limit the number of variables in barchart from crosstabs #58968 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=738cf48684a7dfd5551b113b8245ec8c5ba11c35;p=pspp limit the number of variables in barchart from crosstabs #58968 The barchart was created with more than two variables from the crosstabs subcommand. I added an assertion and limit the number of variables to two. This bug resulted in a regression failure (crash) for test 493: CROSSTABS barchart on i386 architecture. see: https://savannah.gnu.org/bugs/?58968 --- diff --git a/src/language/stats/crosstabs.q b/src/language/stats/crosstabs.q index 11e76cd1da..e8739bc1bf 100644 --- a/src/language/stats/crosstabs.q +++ b/src/language/stats/crosstabs.q @@ -782,10 +782,11 @@ postcalc (struct crosstabs_proc *proc) } if (proc->barchart) { - const struct variable **vars = xcalloc (xt->n_vars, sizeof *vars); - for (size_t i = 0; i < xt->n_vars; i++) + int n_vars = (xt->n_vars > 2 ? 2 : xt->n_vars); + const struct variable **vars = xcalloc (n_vars, sizeof *vars); + for (size_t i = 0; i < n_vars; i++) vars[i] = xt->vars[i].var; - chart_item_submit (barchart_create (vars, xt->n_vars, _("Count"), + chart_item_submit (barchart_create (vars, n_vars, _("Count"), false, xt->entries, xt->n_entries)); free (vars); diff --git a/src/output/charts/barchart.c b/src/output/charts/barchart.c index da72fc89f8..1b7e83ca4f 100644 --- a/src/output/charts/barchart.c +++ b/src/output/charts/barchart.c @@ -160,7 +160,7 @@ barchart_create (const struct variable **var, int n_vars, int width = var_get_width (var[pidx]); - assert (n_vars >= 1); + assert (n_vars >= 1 && n_vars <= 2); bar = xzalloc (sizeof *bar); bar->percent = percent;