From: Ben Pfaff Date: Fri, 1 Jan 2021 02:27:50 +0000 (-0800) Subject: pivot-table: Don't allow data cells for nonexistent categories. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=22203a0e0daa6b6ab247b572b191d25bb48f61a3;p=pspp pivot-table: Don't allow data cells for nonexistent categories. --- diff --git a/src/language/stats/roc.c b/src/language/stats/roc.c index f18964a562..6c3a971bc4 100644 --- a/src/language/stats/roc.c +++ b/src/language/stats/roc.c @@ -1094,6 +1094,13 @@ show_coords (struct roc_state *rs, const struct cmd_roc *roc) const double sp = case_data_idx (cc, ROC_TN)->f / (case_data_idx (cc, ROC_TN)->f + case_data_idx (cc, ROC_FP)->f); + if (coord_idx >= n_coords) + { + assert (coord_idx == n_coords); + pivot_category_create_leaf ( + coordinates->root, pivot_value_new_integer (++n_coords)); + } + pivot_table_put3 ( table, 0, coord_idx, var_idx, pivot_value_new_var_value (roc->vars[i], @@ -1106,16 +1113,9 @@ show_coords (struct roc_state *rs, const struct cmd_roc *roc) coord_idx++; } - if (coord_idx > n_coords) - n_coords = coord_idx; - casereader_destroy (r); } - for (size_t i = 0; i < n_coords; i++) - pivot_category_create_leaf (coordinates->root, - pivot_value_new_integer (i + 1)); - pivot_table_submit (table); } diff --git a/src/output/pivot-table.c b/src/output/pivot-table.c index 5c64671473..4c1b2c7522 100644 --- a/src/output/pivot-table.c +++ b/src/output/pivot-table.c @@ -1057,6 +1057,8 @@ pivot_table_put (struct pivot_table *table, const size_t *dindexes, size_t n, struct pivot_value *value) { assert (n == table->n_dimensions); + for (size_t i = 0; i < n; i++) + assert (dindexes[i] < table->dimensions[i]->n_leaves); if (value->type == PIVOT_VALUE_NUMERIC && !value->numeric.format.w) {