charts: Allow passing a null pointer to chart_unref.
[pspp-builds.git] / src / output / chart.c
index b096a7d2195fc632c863a9e01a7319ea3dceeb80..b1f96ef931b06f6a401c893ddd091271a2e03156 100644 (file)
@@ -114,9 +114,12 @@ chart_ref (const struct chart *chart_)
 void
 chart_unref (struct chart *chart)
 {
-  assert (chart->ref_cnt > 0);
-  if (--chart->ref_cnt == 0)
-    chart->class->destroy (chart);
+  if (chart != NULL)
+    {
+      assert (chart->ref_cnt > 0);
+      if (--chart->ref_cnt == 0)
+        chart->class->destroy (chart);
+    }
 }
 
 void