]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/users.cpp
Cast this to const unsigned char, not just unsigned char. We don't/can't modify them...
[user/henk/code/inspircd.git] / src / users.cpp
index ee35c38787bacaed5e26c7a2b9b12246d8b763cb..f8a95af49a195197042218fb16176f955030c39d 100644 (file)
@@ -193,6 +193,7 @@ User::User(InspIRCd* Instance, const std::string &uid) : ServerInstance(Instance
        Visibility = NULL;
        ip = NULL;
        MyClass = NULL;
+       io = NULL;
        AllowedUserModes = NULL;
        AllowedChanModes = NULL;
        AllowedOperCommands = NULL;
@@ -233,13 +234,13 @@ User::~User()
 
        if (this->AllowedUserModes)
        {
-               delete AllowedUserModes;
+               delete[] AllowedUserModes;
                AllowedUserModes = NULL;
        }
 
        if (this->AllowedChanModes)
        {
-               delete AllowedChanModes;
+               delete[] AllowedChanModes;
                AllowedChanModes = NULL;
        }
 
@@ -704,8 +705,8 @@ void User::Oper(const std::string &opertype, const std::string &opername)
                        if (!AllowedUserModes)
                                AllowedUserModes = new bool[64];
 
-                       memset(AllowedUserModes, 0, 63);
-                       memset(AllowedChanModes, 0, 63);
+                       memset(AllowedUserModes, 0, 64);
+                       memset(AllowedChanModes, 0, 64);
 
                        char* Classes = strdup(iter_opertype->second);
                        char* myclass = strtok_r(Classes," ",&savept);
@@ -727,7 +728,7 @@ void User::Oper(const std::string &opertype, const std::string &opername)
                                        {
                                                if (*c == '*')
                                                {
-                                                       memset(this->AllowedUserModes, (int)(true), 63);
+                                                       memset(this->AllowedUserModes, (int)(true), 64);
                                                }
                                                else
                                                {
@@ -738,7 +739,7 @@ void User::Oper(const std::string &opertype, const std::string &opername)
                                        {
                                                if (*c == '*')
                                                {
-                                                       memset(this->AllowedChanModes, (int)(true), 63);
+                                                       memset(this->AllowedChanModes, (int)(true), 64);
                                                }
                                                else
                                                {
@@ -792,6 +793,17 @@ void User::UnOper()
                        delete AllowedOperCommands;
                        AllowedOperCommands = NULL;
                }
+               if (AllowedUserModes)
+               {
+                       delete[] AllowedUserModes;
+                       AllowedUserModes = NULL;
+               }
+               if (AllowedChanModes)
+               {
+                       delete[] AllowedChanModes;
+                       AllowedChanModes = NULL;
+               }
+
        }
 }
 
@@ -1154,14 +1166,14 @@ void User::Write(std::string text)
                return;
        }
 
-       if (ServerInstance->Config->GetIOHook(this->GetPort()))
+       if (this->io)
        {
                /* XXX: The lack of buffering here is NOT a bug, modules implementing this interface have to
                 * implement their own buffering mechanisms
                 */
                try
                {
-                       ServerInstance->Config->GetIOHook(this->GetPort())->OnRawSocketWrite(this->fd, text.data(), text.length());
+                       this->io->OnRawSocketWrite(this->fd, text.data(), text.length());
                }
                catch (CoreException& modexcept)
                {