Index: ngircd/src/ngircd/client.c
===================================================================
--- ngircd.orig/src/ngircd/client.c	2008-05-26 16:04:44.000000000 -0700
+++ ngircd/src/ngircd/client.c	2008-05-26 16:05:32.000000000 -0700
@@ -251,7 +251,6 @@ Client_Destroy( CLIENT *Client, char *Lo
 {
 	/* Client entfernen. */
 
-	CLIENT *c;
 	char msg[LINE_LEN], *txt;
 #ifdef DEBUG
 	char nickbuf[CLIENT_ID_LEN];
@@ -274,101 +273,103 @@ Client_Destroy( CLIENT *Client, char *Lo
 	if (hashtable_get(&My_Clients, nickbuf) == NULL)
 		LogDebug("Client_Destroy() called for unknown nickname %s!", nickbuf);
 #endif
-	hashtable_iterator_reset(&My_Clients);
-	while(( c = hashtable_iterator_getnext(&My_Clients)))
-	{
-		LogDebug("Testing client nick: %s, want %s", c->id, Client->id);
 
-		if (c != Client) {
-			if ((Client->type == CLIENT_SERVER) && (c->introducer == Client)) {
-				/* The client that is about to be removed is a server,
-				 * the client we are checking right now is a child of that
-				 * server and thus has to be removed, too. */
-				Client_Destroy( c, NULL, msg, false );
-				hashtable_iterator_reset(&My_Clients);
-			}
-			continue;
-		}
-		/* c == Client */
-		switch (c->type) {
-			case CLIENT_USER:
-				if (c->conn_id >= 0) { /* local user */
-					Log(LOG_NOTICE, "User \"%s\" unregistered (connection %d): %s",
-									Client_Mask( c ), c->conn_id, txt);
-					if (SendQuit) {
-						/* inform all other servers */
-						if (FwdMsg) {
-							IRC_WriteStrServersPrefix(NULL,
-									c, "QUIT :%s", FwdMsg );
-						} else {
-							IRC_WriteStrServersPrefix(NULL,
-										c, "QUIT :" );
-						}
-					}
-				} else { /* Remote User */
-					Log(LOG_DEBUG, "User \"%s\" unregistered: %s",
-								Client_Mask( c ), txt );
-				}
+	switch (Client->type) {
+		case CLIENT_USER:
+			if (Client->conn_id >= 0) { /* local user */
+				Log(LOG_NOTICE, "User \"%s\" unregistered (connection %d): %s",
+								Client_Mask( Client ), Client->conn_id, txt);
 				if (SendQuit) {
-					/* inform all other servers, except those
-					 * that are along the clients route (i.e.
-					 * the server that passed this clients QUIT along */
+					/* inform all other servers */
 					if (FwdMsg) {
-						IRC_WriteStrServersPrefix(Client_NextHop(c),
-									c, "QUIT :%s", FwdMsg );
+						IRC_WriteStrServersPrefix(NULL,
+								Client, "QUIT :%s", FwdMsg );
 					} else {
-						IRC_WriteStrServersPrefix(Client_NextHop(c),
-										c, "QUIT :" );
+						IRC_WriteStrServersPrefix(NULL,
+									Client, "QUIT :" );
 					}
 				}
+			} else { /* Remote User */
+				Log(LOG_DEBUG, "User \"%s\" unregistered: %s",
+							Client_Mask( Client ), txt );
+			}
+			if (SendQuit) {
+				/* inform all other servers, except those
+				 * that are along the clients route (i.e.
+				 * the server that passed this clients QUIT along */
+				if (FwdMsg) {
+					IRC_WriteStrServersPrefix(Client_NextHop(Client),
+								Client, "QUIT :%s", FwdMsg );
+				} else {
+					IRC_WriteStrServersPrefix(Client_NextHop(Client),
+									Client, "QUIT :" );
+				}
+			}
 
-				/* Unregister client from channels */
-				Channel_Quit( c, FwdMsg ? FwdMsg : c->id );
+			/* Unregister client from channels */
+			Channel_Quit( Client, FwdMsg ? FwdMsg : Client->id );
 
-				/* Register client in My_Whowas structure */
-				Client_RegisterWhowas( c );
+			/* Register client in My_Whowas structure */
+			Client_RegisterWhowas( Client );
 
-				/* destroy client <-> channel table */
-				hashtable_free(&Client->Cl2Chan);
-			break;
-			case CLIENT_SERVER:
-				if( c != This_Server ) {
-					Log(LOG_NOTICE|LOG_snotice,
-						"Server \"%s\" unregistered (fd %d): %s",
-								c->id, c->conn_id, txt );
-				}
+			/* destroy client <-> channel table */
+			hashtable_free(&Client->Cl2Chan);
+		break;
+		case CLIENT_SERVER:
+			if( Client != This_Server ) {
+				Log(LOG_NOTICE|LOG_snotice,
+					"Server \"%s\" unregistered (fd %d): %s",
+							Client->id, Client->conn_id, txt );
+			}
 
-				/* andere Server informieren */
-				if( ! NGIRCd_SignalQuit ) {
-					if (FwdMsg) {
-						IRC_WriteStrServersPrefix(Client_NextHop(c),
-								c, "SQUIT %s :%s", c->id, FwdMsg );
-					} else {
-						IRC_WriteStrServersPrefix(Client_NextHop(c),
-									c, "SQUIT %s :", c->id );
+			CLIENT *c;
+			hashtable_iterator_reset(&My_Clients);
+			while(( c = hashtable_iterator_getnext(&My_Clients)))
+			{
+				LogDebug("Testing client nick: %s, want %s", c->id, Client->id);
+
+				if (c != Client) {
+					if ((Client->type == CLIENT_SERVER) && (c->introducer == Client)) {
+						/* The client that is about to be removed is a server,
+						 * the client we are checking right now is a child of that
+						 * server and thus has to be removed, too. */
+						Client_Destroy( c, NULL, msg, false );
+						hashtable_iterator_reset(&My_Clients);
 					}
-				} else {
-					Log(LOG_NOTICE,"Client \"%s\" unregistered (fd %d): %s",
-									c->id, c->conn_id, txt );
+					continue;
 				}
-			break;
-			default:
-				LogDebug("Unknown Client type %d", c->type);
-				if( c->conn_id >= 0) {
-					Log( LOG_NOTICE, "Client \"%s\" unregistered (connection %d): %s",
-										c->id, c->conn_id, txt );
+			}
+			hashtable_iterator_reset(&My_Clients);
+
+			/* andere Server informieren */
+			if( ! NGIRCd_SignalQuit ) {
+				if (FwdMsg) {
+					IRC_WriteStrServersPrefix(Client_NextHop(Client),
+							Client, "SQUIT %s :%s", Client->id, FwdMsg );
 				} else {
-					Log(LOG_WARNING, "Unregistered unknown client \"%s\": %s",
-										c->id[0], txt );
+					IRC_WriteStrServersPrefix(Client_NextHop(Client),
+								Client, "SQUIT %s :", Client->id );
 				}
-			break;
-		}
-
-		LogDebug("Remove Nick \"%s\" from hashtable (Destroy)", c->id);
-		hashtable_delete(&My_Clients, c->id);
+			} else {
+				Log(LOG_NOTICE,"Client \"%s\" unregistered (fd %d): %s",
+								Client->id, Client->conn_id, txt );
+			}
+		break;
+		default:
+			LogDebug("Unknown Client type %d", Client->type);
+			if( Client->conn_id >= 0) {
+				Log( LOG_NOTICE, "Client \"%s\" unregistered (connection %d): %s",
+									Client->id, Client->conn_id, txt );
+			} else {
+				Log(LOG_WARNING, "Unregistered unknown client \"%s\": %s",
+									Client->id[0], txt );
+			}
 		break;
 	}
-	hashtable_iterator_reset(&My_Clients);
+
+	LogDebug("Remove Nick \"%s\" from hashtable (Destroy)", Client->id);
+	hashtable_delete(&My_Clients, Client->id);
+
 
 #ifdef DEBUG
 	assert(hashtable_get(&My_Clients, nickbuf) == NULL);
