Trap some bad usage
[pspp-builds.git] / lib / gtksheet / psppire-axis-impl.c
index be47d874c2f88b9f079c2fb9a7b2fa85da81c8ab..b722a87b16c4379a69b9ae4c5198c9b417328725 100644 (file)
@@ -313,7 +313,12 @@ void
 psppire_axis_impl_insert (PsppireAxisImpl *a, gint posn, gint size)
 {
   struct axis_node *before = NULL;
-  struct axis_node *new_node = pool_alloc (a->pool, sizeof (*new_node));
+  struct axis_node *new_node;
+
+  g_return_if_fail ( posn < tower_height (&a->unit_tower));
+  g_return_if_fail ( posn >= 0);
+
+  new_node = pool_alloc (a->pool, sizeof (*new_node));
 
   if ( posn > 0)
     {