From: Ben Pfaff Date: Sun, 7 Jul 2019 04:36:59 +0000 (-0700) Subject: pivot-table: Properly allocate pivot_table's current_layer. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=aaa1b7550afd3e5a85623016883ef29672dbdfba;p=pspp pivot-table: Properly allocate pivot_table's current_layer. The default current_layer should be all-zeros, but the code wasn't allocating current_layer at all. This didn't cause much of a problem because nothing in the current tree allocates layers, but it will as layers are added. Thanks to John Darrington for reporting the bug. --- diff --git a/src/output/pivot-table.c b/src/output/pivot-table.c index 2adcf62634..092ebfc53a 100644 --- a/src/output/pivot-table.c +++ b/src/output/pivot-table.c @@ -279,6 +279,13 @@ pivot_dimension_create__ (struct pivot_table *table, axis->dimensions, (axis->n_dimensions + 1) * sizeof *axis->dimensions); axis->dimensions[axis->n_dimensions++] = d; + if (axis_type == PIVOT_AXIS_LAYER) + { + free (table->current_layer); + table->current_layer = xcalloc (axis[PIVOT_AXIS_LAYER].n_dimensions, + sizeof *table->current_layer); + } + /* XXX extent and label_depth need to be calculated later. */ return d; diff --git a/src/output/pivot-table.h b/src/output/pivot-table.h index c7198a2add..8ea2064405 100644 --- a/src/output/pivot-table.h +++ b/src/output/pivot-table.h @@ -378,7 +378,7 @@ struct pivot_table bool row_labels_in_corner; bool show_grid_lines; bool omit_empty; /* Omit empty rows and columns? */ - size_t *current_layer; /* axis[PIVOT_AXIS_LAYER]->n_dimensions elements. */ + size_t *current_layer; /* axis[PIVOT_AXIS_LAYER].n_dimensions elements. */ char *table_look; enum settings_value_show show_values; enum settings_value_show show_variables;