Fix crash in histogram when all values are missing.
authorJohn Darrington <john@darrington.wattle.id.au>
Thu, 24 Mar 2016 22:13:18 +0000 (23:13 +0100)
committerJohn Darrington <john@darrington.wattle.id.au>
Thu, 24 Mar 2016 22:13:18 +0000 (23:13 +0100)
Found by zzuf.

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

index 424091f9c5c9516816dca0fb1c29671420738141..65c03bbf79dc61985332b2f2123198a45d33a2ef 100644 (file)
@@ -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)
index e3dce9d53870f5aec33108ce4d7c7a97d88d3c8e..b08f9f26d9a52b4d540cfb669b888786313e584a 100644 (file)
@@ -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])