summaryrefslogtreecommitdiff
path: root/src/configreader.cpp
diff options
context:
space:
mode:
authorom <om@e03df62e-2008-0410-955e-edbf42e46eb7>2008-01-03 15:49:57 +0000
committerom <om@e03df62e-2008-0410-955e-edbf42e46eb7>2008-01-03 15:49:57 +0000
commit9354e09fc195d9b174bec06e7f72990e68a23c46 (patch)
treea9f9c9b5aad9c98ce220e35da064bc62f0ab264b /src/configreader.cpp
parent1622a719c7af452127bdd84ea93e4e1c1115be99 (diff)
Hopefully fix crashes on startup with some connect tags (I think when the last connect tag in your config isn't actually used for anything, but I didn't really look into when this is an issue)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@8622 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/configreader.cpp')
-rw-r--r--src/configreader.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/configreader.cpp b/src/configreader.cpp
index 339ae33f8..73c05cf87 100644
--- a/src/configreader.cpp
+++ b/src/configreader.cpp
@@ -521,14 +521,19 @@ bool InitConnect(ServerConfig* conf, const char*)
conf->GetInstance()->Log(DEBUG, "Address of class is %p", c);
}
- for (ClassVector::iterator i = conf->Classes.begin(); i != conf->Classes.end(); i++)
+ for (ClassVector::iterator i = conf->Classes.begin(); i != conf->Classes.end() ; )
{
- ConnectClass *c = *i;
+ ConnectClass* c = *i;
/* only delete a class with refcount 0 */
if (c->RefCount == 0)
{
conf->GetInstance()->Log(DEFAULT, "Removing connect class, refcount is 0!");
+
+ /* This was causing a crash, because we'd set i to .begin() just here, but then the for loop's increment would
+ * set it to .begin() + 1. Which if it was already the last thing in the list, wasn't good.
+ * Now the increment is in the else { } below.
+ */
conf->Classes.erase(i);
i = conf->Classes.begin(); // start over so we don't trample on a bad iterator
}
@@ -536,6 +541,7 @@ bool InitConnect(ServerConfig* conf, const char*)
{
/* also mark all existing classes disabled, if they still exist in the conf, they will be reenabled. */
c->SetDisabled(true);
+ i++;
}
}
@@ -2291,4 +2297,3 @@ bool DoneELine(ServerConfig* conf, const char* tag)
conf->GetInstance()->XLines->CheckELines();
return true;
}
-