diff options
author | Sadie Powell <sadie@witchery.services> | 2023-05-04 17:56:37 +0100 |
---|---|---|
committer | Sadie Powell <sadie@witchery.services> | 2023-05-04 19:21:02 +0100 |
commit | b7abfe5eca076c29a0d49a411320612264093bdf (patch) | |
tree | a8c8adaa95b0aff200b3567677b3da548ebc020c /src/config.cpp | |
parent | 23e7f5bd338cbb78ab3d990ba58064726de42abc (diff) |
Avoid returning null when a config tag does not exist.
This invokes undefined behaviour on modern compilers.
Diffstat (limited to 'src/config.cpp')
-rw-r--r-- | src/config.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/config.cpp b/src/config.cpp index bd9bebe5c..dc9620f1d 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -49,7 +49,7 @@ Block* Block::GetBlock(const Anope::string &bname, int num) for (int i = 0; it.first != it.second; ++it.first, ++i) if (i == num) return &it.first->second; - return NULL; + return &(Config->EmptyBlock); } bool Block::Set(const Anope::string &tag, const Anope::string &value) @@ -116,7 +116,7 @@ template<typename T> static void ValidateNotZero(const Anope::string &block, con throw ConfigException("The value for <" + block + ":" + name + "> cannot be zero!"); } -Conf::Conf() : Block("") +Conf::Conf() : Block(""), EmptyBlock("") { ReadTimeout = 0; UsePrivmsg = DefPrivmsg = false; @@ -602,7 +602,7 @@ void Conf::Post(Conf *old) Block *Conf::GetModule(Module *m) { if (!m) - return NULL; + return &(Config->EmptyBlock); return GetModule(m->name); } @@ -654,7 +654,7 @@ Block *Conf::GetCommand(CommandSource &source) return b; } - return NULL; + return &(Config->EmptyBlock); } File::File(const Anope::string &n, bool e) : name(n), executable(e), fp(NULL) |