summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2014-03-04 04:14:17 -0500
committerAdam <Adam@anope.org>2014-03-04 04:15:32 -0500
commit09bec79b473fad40268f7b25b92c4979563829c4 (patch)
treee5e70c2fd3c6bfbcdb3fbd571c3c0191741b3caa /src
parent55a5affcb8251c6ef677d78ea848dc8d26b90471 (diff)
Fix 2 crashes from removing the permanent channel mode from channels which do not exist
Diffstat (limited to 'src')
-rw-r--r--src/channels.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/channels.cpp b/src/channels.cpp
index a9ad68b93..86c261029 100644
--- a/src/channels.cpp
+++ b/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;