From 2208edf6ff4e97a1f95a43bd96a58b548fbc6100 Mon Sep 17 00:00:00 2001 From: brain Date: Sat, 2 Sep 2006 16:31:59 +0000 Subject: Don't try and delete from the item list whilst iterating it - make a copy instead All modules using u_listmode.h are now unloadable (thats 3 more down) git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@5105 e03df62e-2008-0410-955e-edbf42e46eb7 --- include/u_listmode.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'include') diff --git a/include/u_listmode.h b/include/u_listmode.h index bc6a9fa20..b733d7536 100644 --- a/include/u_listmode.h +++ b/include/u_listmode.h @@ -107,7 +107,13 @@ class ListModeBase : public ModeHandler char moderemove[MAXBUF]; userrec* n = new userrec(ServerInstance); n->SetFd(FD_MAGIC_NUMBER); + modelist copy; + /* Make a copy of it, because we cant change the list whilst iterating over it */ for(modelist::iterator it = el->begin(); it != el->end(); it++) + { + copy.push_back(*it); + } + for(modelist::iterator it = copy.begin(); it != copy.end(); it++) { ServerInstance->Log(DEBUG,"Remove item %s",it->mask.c_str()); sprintf(moderemove,"-%c",this->GetModeChar()); -- cgit v1.2.3