summaryrefslogtreecommitdiff
path: root/src/channels.cpp
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2011-07-10 19:07:45 -0400
committerAdam <Adam@anope.org>2011-08-09 17:25:40 -0400
commit7f4eb852052cb4045cf6cd42bde7030eb558022c (patch)
tree2adf8e09b309edab9cb41c2d71a564ff0065b2d8 /src/channels.cpp
parente9ce53fe8869e6186a04b06b46ca903c1865eba1 (diff)
Bug #1285 - Fixed setting -P on channels with only a service bot in it
(cherry picked from commit b5ec57a3f9fdc9e7c7321392082dec0d475c623c)
Diffstat (limited to 'src/channels.cpp')
-rw-r--r--src/channels.cpp24
1 files changed, 17 insertions, 7 deletions
diff --git a/src/channels.cpp b/src/channels.cpp
index 2fe4e037d..363382bbf 100644
--- a/src/channels.cpp
+++ b/src/channels.cpp
@@ -483,15 +483,19 @@ void Channel::RemoveModeInternal(ChannelMode *cm, const Anope::string &param, bo
{
ci->UnsetFlag(CI_PERSIST);
if (!Config->s_BotServ.empty() && ci->bi && this->FindUser(ci->bi) && Config->BSMinUsers && this->users.size() <= Config->BSMinUsers)
+ {
+ bool empty = this->users.size() == 1;
this->ci->bi->Part(this);
+ if (empty)
+ return;
+ }
}
- }
- /* We set -P in an empty channel, delete the channel */
- if (cm->Name == CMODE_PERM && users.empty())
- {
- delete this;
- return;
+ if (this->users.empty())
+ {
+ delete this;
+ return;
+ }
}
/* Check for mlock */
@@ -698,6 +702,9 @@ void Channel::SetModes(BotInfo *bi, bool EnforceMLock, const char *cmodes, ...)
*/
void Channel::SetModesInternal(User *setter, const Anope::string &mode, bool EnforceMLock)
{
+ /* Removing channel modes *may* delete this channel */
+ dynamic_reference<Channel> this_reference(this);
+
spacesepstream sep_modes(mode);
Anope::string m;
@@ -706,7 +713,7 @@ void Channel::SetModesInternal(User *setter, const Anope::string &mode, bool Enf
Anope::string modestring;
Anope::string paramstring;
int add = -1;
- for (unsigned int i = 0, end = m.length(); i < end; ++i)
+ for (unsigned int i = 0, end = m.length(); i < end && this_reference; ++i)
{
ChannelMode *cm;
@@ -768,6 +775,9 @@ void Channel::SetModesInternal(User *setter, const Anope::string &mode, bool Enf
Log() << "warning: Channel::SetModesInternal() recieved more modes requiring params than params, modes: " << mode;
}
+ if (!this_reference)
+ return;
+
if (setter)
Log(setter, this, "mode") << modestring << paramstring;
else