diff --git a/src/regchannel.cpp b/src/regchannel.cpp index 2a5f09c45..204745e0c 100644 --- a/src/regchannel.cpp +++ b/src/regchannel.cpp @@ -598,6 +598,7 @@ bool ChannelInfo::HasMLock(ChannelMode *mode, const Anope::string ¶m, bool s if (mode->Type != MODE_REGULAR) { std::multimap::const_iterator it_end = this->mode_locks.upper_bound(mode->Name); + for (; it != it_end; ++it) { const ModeLock &ml = it->second; @@ -651,14 +652,18 @@ bool ChannelInfo::RemoveMLock(ChannelMode *mode, const Anope::string ¶m) else { // For list or status modes, we must check the parameter - std::multimap::iterator it = this->mode_locks.find(mode->Name), it_end = this->mode_locks.upper_bound(mode->Name); - for (; it != it_end; ++it) + std::multimap::iterator it = this->mode_locks.find(mode->Name); + if (it != this->mode_locks.end()) { - const ModeLock &ml = it->second; - if (ml.param == param) + std::multimap::iterator it_end = this->mode_locks.upper_bound(mode->Name); + for (; it != it_end; ++it) { - this->mode_locks.erase(it); - return true; + const ModeLock &ml = it->second; + if (ml.param == param) + { + this->mode_locks.erase(it); + return true; + } } } @@ -687,7 +692,10 @@ const std::multimap &ChannelInfo::GetMLock() const */ std::pair ChannelInfo::GetModeList(ChannelModeName Name) { - return std::make_pair(this->mode_locks.find(Name), this->mode_locks.upper_bound(Name)); + std::multimap::iterator it = this->mode_locks.find(Name), it_end = it; + if (it != this->mode_locks.end()) + it_end = this->mode_locks.upper_bound(Name); + return std::make_pair(it, it_end); } /** Get details for a specific mlock