]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/channels.cpp
Fix memory leak in m_filter rehash
[user/henk/code/inspircd.git] / src / channels.cpp
index 8d1c934e0270dcf662d375e5b77e55f6dab5b193..99b118d0dc90e1cb15c0d8e100fa2af2cd0c2803 100644 (file)
@@ -34,27 +34,22 @@ Channel::Channel(InspIRCd* Instance, const std::string &cname, time_t ts) : Serv
 void Channel::SetMode(char mode,bool mode_on)
 {
        modes[mode-65] = mode_on;
-       if (!mode_on)
-               this->SetModeParam(mode,"",false);
 }
 
-
-void Channel::SetModeParam(char mode,const char* parameter,bool mode_on)
+void Channel::SetMode(char mode, std::string parameter)
 {
        CustomModeList::iterator n = custom_mode_params.find(mode);
-
-       if (mode_on)
+       // always erase, even if changing, so that the map gets the new value
+       if (n != custom_mode_params.end())
+               custom_mode_params.erase(n);
+       if (parameter.empty())
        {
-               if (n == custom_mode_params.end())
-                       custom_mode_params[mode] = strdup(parameter);
+               modes[mode-65] = false;
        }
        else
        {
-               if (n != custom_mode_params.end())
-               {
-                       free(n->second);
-                       custom_mode_params.erase(n);
-               }
+               custom_mode_params[mode] = parameter;
+               modes[mode-65] = true;
        }
 }
 
@@ -393,13 +388,10 @@ Channel* Channel::JoinUser(InspIRCd* Instance, User *user, const char* cn, bool
                                        }
                                }
 
-                               if (Ptr->bans.size())
+                               if (Ptr->IsBanned(user) && !can_bypass)
                                {
-                                       if (Ptr->IsBanned(user) && !can_bypass)
-                                       {
-                                               user->WriteNumeric(ERR_BANNEDFROMCHAN, "%s %s :Cannot join channel (You're banned)",user->nick.c_str(), Ptr->name.c_str());
-                                               return NULL;
-                                       }
+                                       user->WriteNumeric(ERR_BANNEDFROMCHAN, "%s %s :Cannot join channel (You're banned)",user->nick.c_str(), Ptr->name.c_str());
+                                       return NULL;
                                }
 
                                /*