From: John Darrington Date: Thu, 24 Mar 2016 22:13:18 +0000 (+0100) Subject: Fix crash in histogram when all values are missing. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6eb8b4b61976de7a648fe8938ac5b6f5af58773c;p=pspp Fix crash in histogram when all values are missing. Found by zzuf. --- diff --git a/src/language/stats/graph.c b/src/language/stats/graph.c index 424091f9c5..65c03bbf79 100644 --- a/src/language/stats/graph.c +++ b/src/language/stats/graph.c @@ -328,7 +328,13 @@ show_histogr (const struct graph *cmd, struct casereader *input) { struct histogram *histogram; struct ccase *c; - + + if (cmd->es[0].cc <= 0) + { + casereader_destroy (input); + return; + } + { /* Sturges Rule */ double bin_width = fabs (cmd->es[0].minimum - cmd->es[0].maximum) diff --git a/tests/language/stats/graph.at b/tests/language/stats/graph.at index e3dce9d538..b08f9f26d9 100644 --- a/tests/language/stats/graph.at +++ b/tests/language/stats/graph.at @@ -165,6 +165,23 @@ dnl Ignore output -- this is just a no-crash check. AT_CLEANUP +AT_SETUP([GRAPH histogram all missing]) +AT_DATA([null-hist.sps], [dnl +data list list /x *. +begin data. +. +end data. + +graph + /histogram = x. + +]) + +AT_CHECK([pspp null-hist.sps], [0], [ignore]) +dnl Ignore output -- this is just a no-crash check. +AT_CLEANUP + + AT_SETUP([GRAPH barcharts])