]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/configreader.cpp
Hopefully fix crashes on startup with some connect tags (I think when the last connec...
[user/henk/code/inspircd.git] / src / configreader.cpp
index 339ae33f8cc3ec99103471ae96a055c410660624..73c05cf87fc01ce94faffbf3f903ea58efd2a852 100644 (file)
@@ -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;
+               ConnectClassc = *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;
 }
-