Don't crash during interface up/down events.
diff --git a/isisd/ChangeLog b/isisd/ChangeLog
index 93a901b..e883faa 100644
--- a/isisd/ChangeLog
+++ b/isisd/ChangeLog
@@ -1,3 +1,9 @@
+2004-12-29 Hasso Tepper <hasso at quagga.net>
+
+	* isis_circuit.c, isis_csm.c, isis_zebra.c: Don't crash during
+	  interface up/down events. I'm not sure whether logic is correct
+	  though. Needs rethink anyway, seems.
+
 2004-12-24 Hasso Tepper <hasso at quagga.net>
 
 	* *.c: zlog_* cleanup. Mostly changed level of debug messages to
diff --git a/isisd/isis_circuit.c b/isisd/isis_circuit.c
index c00e88f..ca5befb 100644
--- a/isisd/isis_circuit.c
+++ b/isisd/isis_circuit.c
@@ -191,8 +191,10 @@
   if (circuit->circ_type == CIRCUIT_T_BROADCAST)
     {
       /* destroy adjacency databases */
-      list_delete (circuit->u.bc.adjdb[0]);
-      list_delete (circuit->u.bc.adjdb[1]);
+      if (circuit->u.bc.adjdb[0])
+	list_delete (circuit->u.bc.adjdb[0]);
+      if (circuit->u.bc.adjdb[1])
+	list_delete (circuit->u.bc.adjdb[1]);
       /* destroy neighbour lists */
       if (circuit->u.bc.lan_neighs[0])
 	list_delete (circuit->u.bc.lan_neighs[0]);
@@ -428,7 +430,12 @@
 isis_circuit_update_params (struct isis_circuit *circuit,
 			    struct interface *ifp)
 {
-  assert (circuit);
+  /* HT: It can happen at the moment during interface up event because we
+   * actually delete circuit during interface down event. Should be really
+   * cleaned up. TODO */
+  /* assert (circuit); */
+  if (!circuit)
+    return;
 
   if (circuit->circuit_id != ifp->ifindex)
     {
diff --git a/isisd/isis_csm.c b/isisd/isis_csm.c
index 8e57d39..58a0b29 100644
--- a/isisd/isis_csm.c
+++ b/isisd/isis_csm.c
@@ -125,6 +125,7 @@
 	  isis_circuit_if_del (circuit);
 	  listnode_delete (isis->init_circ_list, circuit);
 	  isis_circuit_del (circuit);
+	  circuit = NULL;
 	  break;
 	}
       break;
@@ -143,6 +144,7 @@
 	case ISIS_DISABLE:
 	  isis_circuit_deconfigure (circuit, (struct isis_area *) arg);
 	  isis_circuit_del (circuit);
+	  circuit = NULL;
 	  break;
 	case IF_DOWN_FROM_Z:
 	  zlog_warn ("circuit already disconnected");
diff --git a/isisd/isis_zebra.c b/isisd/isis_zebra.c
index c7d0533..bcd0018 100644
--- a/isisd/isis_zebra.c
+++ b/isisd/isis_zebra.c
@@ -135,6 +135,9 @@
   if (if_is_up (ifp))
     {
       zebra_interface_if_set_value (zclient->ibuf, ifp);
+      /* HT: This is wrong actually. We can't assume that circuit exist
+       * if we delete circuit during if_state_down event. Needs rethink.
+       * TODO */
       isis_circuit_update_params (circuit_scan_by_ifp (ifp), ifp);
       return 0;
     }