diff options
author | Adam <Adam@anope.org> | 2017-10-26 20:23:24 -0400 |
---|---|---|
committer | Adam <Adam@anope.org> | 2017-10-26 20:23:24 -0400 |
commit | 7b7953aaf2aa0895604e57fe0136ba9a5831349c (patch) | |
tree | fe09fc0b5f8d2c8279061cc00aea0496298e4f1e /src/modules.cpp | |
parent | 7e4cc45149f41346f18e581cb301a1196b92bf68 (diff) |
ConfigReader: fix compilers optimizing NULL check in ConfigTag::readString()
See: 66f82ccf926aac39273bfc652c85c08080cc9a46
Fixes inspircd/inspircd-extras#110
Diffstat (limited to 'src/modules.cpp')
-rw-r--r-- | src/modules.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/modules.cpp b/src/modules.cpp index b2d2f23c6..79a33e617 100644 --- a/src/modules.cpp +++ b/src/modules.cpp @@ -641,7 +641,8 @@ static ConfigTag* SlowGetTag(const std::string &tag, int index) std::string ConfigReader::ReadValue(const std::string &tag, const std::string &name, const std::string &default_value, int index, bool allow_linefeeds) { std::string result = default_value; - if (!SlowGetTag(tag, index)->readString(name, result, allow_linefeeds)) + ConfigTag* conftag = SlowGetTag(tag, index); + if (!conftag || !conftag->readString(name, result, allow_linefeeds)) { this->error = CONF_VALUE_NOT_FOUND; } @@ -656,7 +657,8 @@ std::string ConfigReader::ReadValue(const std::string &tag, const std::string &n bool ConfigReader::ReadFlag(const std::string &tag, const std::string &name, const std::string &default_value, int index) { bool def = (default_value == "yes"); - return SlowGetTag(tag, index)->getBool(name, def); + ConfigTag* conftag = SlowGetTag(tag, index); + return conftag ? conftag->getBool(name, def) : def; } bool ConfigReader::ReadFlag(const std::string &tag, const std::string &name, int index) @@ -668,7 +670,8 @@ bool ConfigReader::ReadFlag(const std::string &tag, const std::string &name, int int ConfigReader::ReadInteger(const std::string &tag, const std::string &name, const std::string &default_value, int index, bool need_positive) { int v = atoi(default_value.c_str()); - int result = SlowGetTag(tag, index)->getInt(name, v); + ConfigTag* conftag = SlowGetTag(tag, index); + int result = conftag ? conftag->getInt(name, v) : v; if ((need_positive) && (result < 0)) { |