--- p_sethost.c.orig	Mon Nov  5 08:49:37 2001
+++ p_sethost.c	Tue Aug 21 04:24:45 2001
@@ -37,6 +37,7 @@
 #include "send.h"
 #include "s_conf.h"
 #include "s_user.h"
+#include "s_debug.h"
 #include "userload.h"
 
 #include <string.h>
@@ -94,6 +95,7 @@
 int m_sethost(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
 {
   struct Membership *lp;
+  struct Membership *lpp;
   struct SLink *lp2;
   struct Channel *chptr;
   struct User *user = sptr->user;
@@ -304,7 +306,10 @@
     if(lp = sptr->user->channel)
     {
       for (; lp->next_channel; lp = lp->next_channel);
-      for (; lp; lp = lp->prev_channel) {
+      lpp = lp->prev_channel;
+      for (; lp; lp = lpp)
+      {
+         lpp = lp->prev_channel;
          chptr = lp->channel;
          strcat(chandb,chptr->chname);    /* Cache channel (for readding later) */
       
