charts: Allow passing a null pointer to chart_unref.
authorBen Pfaff <blp@gnu.org>
Mon, 20 Jul 2009 00:11:46 +0000 (17:11 -0700)
committerBen Pfaff <blp@gnu.org>
Mon, 20 Jul 2009 00:11:53 +0000 (17:11 -0700)
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