]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/users.cpp
This fixes a deletion error here, we were using new[] and not using delete[], but...
[user/henk/code/inspircd.git] / src / users.cpp
index 35a0e716fe50ecb88639e4078a25a61a65dc9227..8ab475bd9e9278754cb80ee0ab9df05b42b2bdf9 100644 (file)
@@ -309,13 +309,18 @@ const char* userrec::FormatModes()
 
 void userrec::DecrementModes()
 {
-       for (int n = 0; n < 64; n++)
+       ServerInstance->Log(DEBUG,"DecrementModes()");
+       for (unsigned char n = 'A'; n <= 'z'; n++)
        {
-               if (modes[n])
+               if (modes[n-65])
                {
-                       ModeHandler* mh = ServerInstance->Modes->FindMode(n+65, MODETYPE_USER);
+                       ServerInstance->Log(DEBUG,"DecrementModes() found mode %c", n);
+                       ModeHandler* mh = ServerInstance->Modes->FindMode(n, MODETYPE_USER);
                        if (mh)
+                       {
+                               ServerInstance->Log(DEBUG,"Found handler %c and call ChangeCount", n);
                                mh->ChangeCount(-1);
+                       }
                }
        }
 }
@@ -830,16 +835,9 @@ void userrec::UnOper()
                        // unset their oper type (what IS_OPER checks), and remove +o
                        *this->oper = 0;
                        this->modes[UM_OPERATOR] = 0;
-
-                       // remove them from the opers list.
-                       for (std::vector<userrec*>::iterator a = ServerInstance->all_opers.begin(); a < ServerInstance->all_opers.end(); a++)
-                       {
-                               if (*a == this)
-                               {
-                                       ServerInstance->all_opers.erase(a);
-                                       return;
-                               }
-                       }
+                       
+                       // remove the user from the oper list. Will remove multiple entries as a safeguard against bug #404
+                       ServerInstance->all_opers.remove(this);
                }
        }
 
@@ -873,7 +871,18 @@ void userrec::AddClient(InspIRCd* Instance, int socket, int port, bool iscached,
        /* NOTE: Calling this one parameter constructor for userrec automatically
         * allocates a new UUID and places it in the hash_map.
         */
-       userrec* New = new userrec(Instance);
+       userrec* New = NULL;
+       try
+       {
+               New = new userrec(Instance);
+       }
+       catch (...)
+       {
+               Instance->Log(DEFAULT,"*** WTF *** Duplicated UUID! -- Crack smoking monkies have been unleashed.");
+               Instance->WriteOpers("*** WARNING *** Duplicate UUID allocated!");
+               return;
+       }
+
        int j = 0;
 
        Instance->unregistered_count++;
@@ -1374,7 +1383,7 @@ void userrec::Write(std::string text)
 
        try
        {
-               /* ServerInstance->Log(DEBUG,"C[%d] <- %s", this->GetFd(), text.c_str());
+               /* ServerInstance->Log(DEBUG,"C[%d] O %s", this->GetFd(), text.c_str());
                 * WARNING: The above debug line is VERY loud, do NOT
                 * enable it till we have a good way of filtering it
                 * out of the logs (e.g. 1.2 would be good).