[isisd] Bug #437: fix ssert caused by bad list management

2008-01-29 James Carlson <james.d.carlson@sun.com>

	* Fix bug #437, assert due to bogus index management
	* isis_flags.c: (flags_initialize) new
	* (flags_get_index) fix off by one, leading to list assert
	  on null node data.
	  (flags_free_index) ditto.
	* isisd.c: (isis_area_create) use flags_initialize
	  (isis_area_destroy) deconfigure circuits when
	  taking down area.
diff --git a/isisd/isisd.c b/isisd/isisd.c
index 48ea47a..7c669fc 100644
--- a/isisd/isisd.c
+++ b/isisd/isisd.c
@@ -130,7 +130,7 @@
   area->circuit_list = list_new ();
   area->area_addrs = list_new ();
   THREAD_TIMER_ON (master, area->t_tick, lsp_tick, area, 1);
-  area->flags.maxindex = -1;
+  flags_initialize (&area->flags);
   /*
    * Default values
    */
@@ -215,7 +215,11 @@
   if (area->circuit_list)
     {
       for (ALL_LIST_ELEMENTS (area->circuit_list, node, nnode, circuit))
-        isis_circuit_del (circuit);
+	{
+	  /* The fact that it's in circuit_list means that it was configured */
+	  isis_circuit_deconfigure (circuit, area);
+	  isis_circuit_del (circuit);
+	}
       
       list_delete (area->circuit_list);
     }