diff options
-rw-r--r-- | modules/commands/cs_mode.cpp | 2 | ||||
-rw-r--r-- | modules/commands/os_mode.cpp | 14 |
2 files changed, 11 insertions, 5 deletions
diff --git a/modules/commands/cs_mode.cpp b/modules/commands/cs_mode.cpp index 8a30f102c..b11bc8862 100644 --- a/modules/commands/cs_mode.cpp +++ b/modules/commands/cs_mode.cpp @@ -487,7 +487,7 @@ class CommandCSMode : public Command case '*': if (adding == -1 || !has_access) break; - for (unsigned j = 0; j < ModeManager::GetChannelModes().size(); ++j) + for (unsigned j = 0; j < ModeManager::GetChannelModes().size() && ci->c; ++j) { ChannelMode *cm = ModeManager::GetChannelModes()[j]; diff --git a/modules/commands/os_mode.cpp b/modules/commands/os_mode.cpp index 379879844..b6f26c7b3 100644 --- a/modules/commands/os_mode.cpp +++ b/modules/commands/os_mode.cpp @@ -26,7 +26,7 @@ class CommandOSMode : public Command const Anope::string &target = params[0]; const Anope::string &modes = params[1]; - Channel *c = Channel::Find(target); + Reference<Channel> c = Channel::Find(target); if (!c) source.Reply(CHAN_X_NOT_IN_USE, target.c_str()); else if (c->bouncy_modes) @@ -36,9 +36,15 @@ class CommandOSMode : public Command bool all = params.size() > 2 && params[2].equals_ci("ALL"); const Channel::ModeList chmodes = c->GetModes(); - for (Channel::ModeList::const_iterator it = chmodes.begin(), it_end = chmodes.end(); it != it_end; ++it) + for (Channel::ModeList::const_iterator it = chmodes.begin(), it_end = chmodes.end(); it != it_end && c; ++it) c->RemoveMode(c->ci->WhoSends(), it->first, it->second, false); + if (!c) + { + source.Reply(_("Modes cleared on %s and the channel destroyed."), target.c_str()); + return; + } + if (all) { for (Channel::ChanUserList::iterator it = c->users.begin(), it_end = c->users.end(); it != it_end; ++it) @@ -65,7 +71,7 @@ class CommandOSMode : public Command Anope::string log_modes, log_params; sep.GetToken(mode); - for (unsigned i = 0; i < mode.length(); ++i) + for (unsigned i = 0; i < mode.length() && c; ++i) { char ch = mode[i]; @@ -116,7 +122,7 @@ class CommandOSMode : public Command } if (!log_modes.replace_all_cs("+", "").replace_all_cs("-", "").empty()) - Log(LOG_ADMIN, source, this) << log_modes << log_params << " on " << c->name; + Log(LOG_ADMIN, source, this) << log_modes << log_params << " on " << (c ? c->name : target); } } |