X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flanguage%2Fstats%2Fctables.c;fp=src%2Flanguage%2Fstats%2Fctables.c;h=59c97ecdc20e8714de04ae1e1858b8bfad71c0df;hb=b34f0edb35583029454da7e28aa5e8121da42170;hp=930c09c6331e8a7eb33e38726ae447e85cc0a8aa;hpb=48ff512fdcc7ebd38013837789eaf6b2a87f5251;p=pspp diff --git a/src/language/stats/ctables.c b/src/language/stats/ctables.c index 930c09c633..59c97ecdc2 100644 --- a/src/language/stats/ctables.c +++ b/src/language/stats/ctables.c @@ -4213,24 +4213,30 @@ ctables_cell_postcompute (const struct ctables_section *s, size_t *pc_a_idx_p) { assert (cell->postcompute); - for (enum pivot_axis_type pc_a = 0; ; pc_a++) - { - assert (pc_a < PIVOT_N_AXES); - for (size_t pc_a_idx = 0; pc_a_idx < s->nests[pc_a]->n; pc_a_idx++) - { - const struct ctables_cell_value *cv = &cell->axes[pc_a].cvs[pc_a_idx]; - if (cv->category->type == CCT_POSTCOMPUTE) - { - if (pc_a_p) - *pc_a_p = pc_a; - if (pc_a_idx_p) - *pc_a_idx_p = pc_a_idx; - return cv->category->pc; - } - } - } + const struct ctables_postcompute *pc = NULL; + for (enum pivot_axis_type pc_a = 0; pc_a < PIVOT_N_AXES; pc_a++) + for (size_t pc_a_idx = 0; pc_a_idx < s->nests[pc_a]->n; pc_a_idx++) + { + const struct ctables_cell_value *cv = &cell->axes[pc_a].cvs[pc_a_idx]; + if (cv->category->type == CCT_POSTCOMPUTE) + { + if (pc) + { + /* Multiple postcomputes cross each other. The value is + undefined. */ + return NULL; + } - NOT_REACHED (); + pc = cv->category->pc; + if (pc_a_p) + *pc_a_p = pc_a; + if (pc_a_idx_p) + *pc_a_idx_p = pc_a_idx; + } + } + + assert (pc != NULL); + return pc; } static double @@ -4245,6 +4251,8 @@ ctables_cell_calculate_postcompute (const struct ctables_section *s, size_t pc_a_idx; const struct ctables_postcompute *pc = ctables_cell_postcompute ( s, cell, &pc_a, &pc_a_idx); + if (!pc) + return SYSMIS; if (pc->specs) {