Fixed a bug where frequencies/histogram would crash when all data had missing wieghts.
authorJohn Darrington <john@darrington.wattle.id.au>
Thu, 31 Mar 2016 19:51:25 +0000 (21:51 +0200)
committerJohn Darrington <john@darrington.wattle.id.au>
Thu, 31 Mar 2016 19:55:06 +0000 (21:55 +0200)
Found by zzuf.

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

index dc18ed83c79589cf3c028cc872e84fb934dabfe8..cb963897786d6f19c9c44cb8b12dca5cc4f1a460 100644 (file)
@@ -1324,6 +1324,8 @@ freq_tab_to_hist (const struct frq_proc *frq, const struct freq_tab *ft,
         }
     }
 
+  if (valid_freq <= 0)
+    return NULL;
 
   iqr = calculate_iqr (frq);
 
index 0d6433c5b938c7eb25bdea3a3bb2367b987d6b4d..f0d81c321075d4edec21af52a38520acf88fd03a 100644 (file)
@@ -739,3 +739,25 @@ Percentiles,,.
 ])
 
 AT_CLEANUP
+
+
+AT_SETUP([FREQUENCIES histogram no valid cases])
+AT_DATA([empty.sps], [dnl
+data list notable list /x w *.
+begin data.
+1 .
+2 .
+3 .
+end data.
+
+weight by w.
+
+FREQUENCIES
+       /VARIABLES = x
+       /histogram
+       .
+])
+
+AT_CHECK([pspp empty.sps -O format=csv], [0],  [ignore])
+
+AT_CLEANUP