Fixed bug #14822.
[pspp-builds.git] / src / plot-hist.c
index 15578879e1eba6fe9679225e15cd67565e53c23e..fd1a88d8a69cfbb325723522707eaf8471ff565c 100644 (file)
@@ -41,7 +41,7 @@ histogram_write_legend(struct chart *ch, const struct normal_curve *norm)
 {
   char buf[100];
   if ( !ch )
-         return ;
+    return ;
 
   pl_savestate_r(ch->lp);
 
@@ -121,14 +121,22 @@ histogram_plot(const gsl_histogram *hist,
   
   struct chart *ch;
 
-  bins = gsl_histogram_bins(hist);
-
   ch = chart_create();
   chart_write_title(ch, _("HISTOGRAM"));
 
   chart_write_ylabel(ch, _("Frequency"));
   chart_write_xlabel(ch, factorname);
 
+  if ( ! hist ) /* If this happens, probably all values are SYSMIS */
+    {
+      chart_submit(ch);
+      return ;
+    }
+  else
+    {
+      bins = gsl_histogram_bins(hist);
+    }
+
   chart_write_yscale(ch, 0, gsl_histogram_max_val(hist), 5);
 
   for ( i = 0 ; i < bins ; ++i )