]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_cap.cpp
Fix segfault in m_chanprotect when OnAccessCheck is called with a null channel
[user/henk/code/inspircd.git] / src / modules / m_cap.cpp
index b8abd1b02116d0d5a2e2307ec772ac7953bd460b..626b4c23c33169ee728300424f6998e62588a3a5 100644 (file)
@@ -3,7 +3,7 @@
  *       +------------------------------------+
  *
  *  InspIRCd: (C) 2002-2009 InspIRCd Development Team
- * See: http://www.inspircd.org/wiki/index.php/Credits
+ * See: http://wiki.inspircd.org/Credits
  *
  * This program is free but copyrighted software; see
  *            the file COPYING for details.
@@ -34,11 +34,9 @@ CAP END
  */
 class CommandCAP : public Command
 {
-       Module* Creator;
  public:
-       CommandCAP (InspIRCd* Instance, Module* mod) : Command(Instance,"CAP", 0, 1, true), Creator(mod)
+       CommandCAP (InspIRCd* Instance, Module* mod) : Command(Instance, mod, "CAP", 0, 1, true)
        {
-               this->source = "m_cap.so";
        }
 
        CmdResult Handle (const std::vector<std::string> &parameters, User *user)
@@ -51,7 +49,7 @@ class CommandCAP : public Command
 
                        Data.type = subcommand;
                        Data.user = user;
-                       Data.creator = this->Creator;
+                       Data.creator = this->creator;
 
                        if (parameters.size() < 2)
                                return CMD_FAILURE;
@@ -67,7 +65,7 @@ class CommandCAP : public Command
                        }
 
                        user->Extend("CAP_REGHOLD");
-                       Event event((char*) &Data, (Module*)this->Creator, "cap_req");
+                       Event event((char*) &Data, this->creator, "cap_req");
                        event.Send(this->ServerInstance);
 
                        if (Data.ack.size() > 0)
@@ -92,10 +90,10 @@ class CommandCAP : public Command
 
                        Data.type = subcommand;
                        Data.user = user;
-                       Data.creator = this->Creator;
+                       Data.creator = this->creator;
 
                        user->Extend("CAP_REGHOLD");
-                       Event event((char*) &Data, (Module*)this->Creator, subcommand == "LS" ? "cap_ls" : "cap_list");
+                       Event event((char*) &Data, this->creator, subcommand == "LS" ? "cap_ls" : "cap_list");
                        event.Send(this->ServerInstance);
 
                        std::string Result;
@@ -112,10 +110,10 @@ class CommandCAP : public Command
 
                        Data.type = subcommand;
                        Data.user = user;
-                       Data.creator = this->Creator;
+                       Data.creator = this->creator;
 
                        user->Extend("CAP_REGHOLD");
-                       Event event((char*) &Data, (Module*)this->Creator, "cap_clear");
+                       Event event((char*) &Data, this->creator, "cap_clear");
                        event.Send(this->ServerInstance);
 
                        std::string Result = irc::stringjoiner(" ", Data.ack, 0, Data.ack.size() - 1).GetJoined();
@@ -132,26 +130,24 @@ class CommandCAP : public Command
 
 class ModuleCAP : public Module
 {
-       CommandCAP* newcommand;
+       CommandCAP newcommand;
  public:
        ModuleCAP(InspIRCd* Me)
-               : Module(Me)
+               : Module(Me), newcommand(Me, this)
        {
-               // Create a new command
-               newcommand = new CommandCAP(ServerInstance, this);
-               ServerInstance->AddCommand(newcommand);
+               ServerInstance->AddCommand(&newcommand);
 
                Implementation eventlist[] = { I_OnCheckReady };
                ServerInstance->Modules->Attach(eventlist, this, 1);
        }
 
-       virtual bool OnCheckReady(User* user)
+       virtual ModResult OnCheckReady(User* user)
        {
                /* Users in CAP state get held until CAP END */
                if (user->GetExt("CAP_REGHOLD"))
-                       return false;
+                       return MOD_RES_DENY;
 
-               return true;
+               return MOD_RES_PASSTHRU;
        }
 
        virtual ~ModuleCAP()