Fixed bug GRAPH /HISTOGRAM vs. null data.
authorJohn Darrington <john@darrington.wattle.id.au>
Tue, 2 Jun 2015 08:26:06 +0000 (10:26 +0200)
committerJohn Darrington <john@darrington.wattle.id.au>
Tue, 2 Jun 2015 08:26:06 +0000 (10:26 +0200)
Fixed a crash which occured when GRAPH /HISTOGRAM was called
on a dataset with less than 2 data.'

src/language/stats/graph.c
tests/language/stats/graph.at

index ae80616862f7aeda14e42e49a1b78609ccb860f4..b695f4c94a4f671fc7325304891e7c69e7dd227e 100644 (file)
@@ -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))
     {
index f4b125b24eda71f344ae4bee8113c5762f5f3174..ae716a3b8d669a9b55f14b3eca7af5d8ad631469 100644 (file)
@@ -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