From ab0f16ff4bf644918474042c4f6b0ae7b71aeb78 Mon Sep 17 00:00:00 2001 From: John Darrington Date: Tue, 2 Jun 2015 10:26:06 +0200 Subject: [PATCH] Fixed bug GRAPH /HISTOGRAM vs. null data. Fixed a crash which occured when GRAPH /HISTOGRAM was called on a dataset with less than 2 data.' --- src/language/stats/graph.c | 5 +++++ tests/language/stats/graph.at | 16 ++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/src/language/stats/graph.c b/src/language/stats/graph.c index ae80616862..b695f4c94a 100644 --- a/src/language/stats/graph.c +++ b/src/language/stats/graph.c @@ -189,6 +189,11 @@ show_histogr (const struct graph *cmd, struct casereader *input) histogram_create (bin_width, cmd->es[0].minimum, cmd->es[0].maximum); } + if (NULL == histogram) + { + casereader_destroy (input); + return; + } for (;(c = casereader_read (input)) != NULL; case_unref (c)) { diff --git a/tests/language/stats/graph.at b/tests/language/stats/graph.at index f4b125b24e..ae716a3b8d 100644 --- a/tests/language/stats/graph.at +++ b/tests/language/stats/graph.at @@ -147,3 +147,19 @@ dnl Ignore output -- this is just a no-crash check. AT_CLEANUP +AT_SETUP([GRAPH histogram with null data]) +AT_DATA([null-hist.sps], [dnl +data list list /x *. +begin data. +1109 +. +end data. + +graph + /histogram = x. + +]) + +AT_CHECK([pspp -o pspp.pdf null-hist.sps], [0], [ignore]) +dnl Ignore output -- this is just a no-crash check. +AT_CLEANUP -- 2.30.2