From 221e79f50d59eff98a2c671332bf9d92dbe35dd5 Mon Sep 17 00:00:00 2001 From: Adam Date: Thu, 21 Mar 2013 23:33:40 -0500 Subject: Check for null pointers in HasMLock/SetMLock/RemoveMLock, cs_register can pass it some sometimes/possibly other places --- src/regchannel.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/regchannel.cpp b/src/regchannel.cpp index c4c02ad0e..2af652d8e 100644 --- a/src/regchannel.cpp +++ b/src/regchannel.cpp @@ -762,6 +762,9 @@ void ChannelInfo::ClearBadWords() bool ChannelInfo::HasMLock(ChannelMode *mode, const Anope::string ¶m, bool status) const { + if (!mode) + return false; + std::multimap::const_iterator it = this->mode_locks->find(mode->name); if (it != this->mode_locks->end()) @@ -785,6 +788,9 @@ bool ChannelInfo::HasMLock(ChannelMode *mode, const Anope::string ¶m, bool s bool ChannelInfo::SetMLock(ChannelMode *mode, bool status, const Anope::string ¶m, Anope::string setter, time_t created) { + if (!mode) + return false; + if (setter.empty()) setter = this->founder ? this->founder->display : "Unknown"; std::pair ml = std::make_pair(mode->name, new ModeLock(this, status, mode->name, param, setter, created)); @@ -827,6 +833,9 @@ bool ChannelInfo::SetMLock(ChannelMode *mode, bool status, const Anope::string & bool ChannelInfo::RemoveMLock(ChannelMode *mode, bool status, const Anope::string ¶m) { + if (!mode) + return false; + if (mode->type == MODE_REGULAR || mode->type == MODE_PARAM) { ChannelInfo::ModeList::iterator it = this->mode_locks->find(mode->name), it_end = this->mode_locks->upper_bound(mode->name), it_next = it; -- cgit