From: Friedrich Beckmann Date: Sat, 4 Jun 2016 22:41:05 +0000 (+0200) Subject: frequencies: fixed bug #48128 in percentiles X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=86642e66638412248901e54a4392882c32d83a71;p=pspp frequencies: fixed bug #48128 in percentiles The frequencies command crashed with a certain combination of percentiles and histogram options. The bug was reported by Cubyrk Zyrvay in http://lists.gnu.org/archive/html/bug-gnu-pspp/2016-06/msg00000.html Closes bug #48128 --- diff --git a/src/language/stats/frequencies.c b/src/language/stats/frequencies.c index 34da71c8aa..675a02319a 100644 --- a/src/language/stats/frequencies.c +++ b/src/language/stats/frequencies.c @@ -1124,6 +1124,7 @@ cmd_frequencies (struct lexer *lexer, struct dataset *ds) frq.percentiles[frq.n_percentiles].show = true; frq.n_percentiles++; + frq.n_show_percentiles++; } @@ -1212,19 +1213,20 @@ cmd_frequencies (struct lexer *lexer, struct dataset *ds) frq.n_show_percentiles = 0; for (i = o = 0; i < frq.n_percentiles; ++i) { - frq.percentiles[o].p = frq.percentiles[i].p; - - if (frq.percentiles[i].show) - frq.percentiles[o].show = true; - - if (frq.percentiles[i].p != previous_p) - { - if (frq.percentiles[i].show) - frq.n_show_percentiles++; - - o++; - } - + if (frq.percentiles[i].p != previous_p) + { + frq.percentiles[o].p = frq.percentiles[i].p; + frq.percentiles[o].show = frq.percentiles[i].show; + if (frq.percentiles[i].show) + frq.n_show_percentiles++; + o++; + } + else if (frq.percentiles[i].show && + !frq.percentiles[o].show) + { + frq.percentiles[o].show = true; + frq.n_show_percentiles++; + } previous_p = frq.percentiles[i].p; }