Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix 2 crashes from removing the permanent channel mode from channels …

…which do not exist
  • Loading branch information...
commit 09bec79b473fad40268f7b25b92c4979563829c4 1 parent 55a5aff
@Adam- Adam- authored
View
2  include/modules.h
@@ -1010,7 +1010,7 @@ class CoreExport Module : public Extensible
* mostly to ensure mlock/+r are set.
* @param c The channel
*/
- virtual void OnCheckModes(Channel *c) { throw NotImplementedException(); }
+ virtual void OnCheckModes(Reference<Channel> &c) { throw NotImplementedException(); }
/** Called when a channel is synced.
* Channels are synced after a sjoin is finished processing
View
4 modules/commands/cs_mode.cpp
@@ -902,9 +902,9 @@ class CSMode : public Module
}
}
- void OnCheckModes(Channel *c) anope_override
+ void OnCheckModes(Reference<Channel> &c) anope_override
{
- if (!c->ci)
+ if (!c || !c->ci)
return;
ModeLocks *locks = modelocks.Get(c->ci);
View
6 modules/commands/cs_set.cpp
@@ -1289,12 +1289,6 @@ class CSSet : public Module
{
if (c->ci)
persist.Unset(c->ci);
-
- if (c->CheckDelete())
- {
- delete c;
- return EVENT_STOP;
- }
}
if (c->ci && mode->type != MODE_STATUS && !c->syncing && Me->IsSynced())
View
5 modules/pseudoclients/chanserv.cpp
@@ -274,8 +274,11 @@ class ChanServCore : public Module, public ChanServService
"lists and settings for any channel."));
}
- void OnCheckModes(Channel *c) anope_override
+ void OnCheckModes(Reference<Channel> &c) anope_override
{
+ if (!c)
+ return;
+
if (c->ci)
c->SetMode(c->ci->WhoSends(), "REGISTERED", "", false);
else
View
16 src/channels.cpp
@@ -111,7 +111,8 @@ void Channel::CheckModes()
return;
}
- FOREACH_MOD(OnCheckModes, (this));
+ Reference<Channel> ref = this;
+ FOREACH_MOD(OnCheckModes, (ref));
}
bool Channel::CheckDelete()
@@ -371,6 +372,15 @@ void Channel::RemoveModeInternal(MessageSource &setter, ChannelMode *cm, const A
FOREACH_RESULT(OnChannelModeUnset, MOD_RESULT, (this, setter, cm, param));
+ if (cm->name == "PERM")
+ {
+ if (this->CheckDelete())
+ {
+ delete this;
+ return;
+ }
+ }
+
/* Check for mlock */
if (!enforce_mlock || MOD_RESULT == EVENT_STOP)
return;
@@ -505,9 +515,11 @@ void Channel::SetModes(BotInfo *bi, bool enforce_mlock, const char *cmodes, ...)
vsnprintf(buf, BUFSIZE - 1, cmodes, args);
va_end(args);
+ Reference<Channel> this_reference(this);
+
spacesepstream sep(buf);
sep.GetToken(modebuf);
- for (unsigned i = 0, end = modebuf.length(); i < end; ++i)
+ for (unsigned i = 0, end = modebuf.length(); this_reference && i < end; ++i)
{
ChannelMode *cm;
Please sign in to comment.
Something went wrong with that request. Please try again.