mirror of
https://github.com/inspircd/inspircd.git
synced 2025-03-10 02:59:01 -04:00
Avoid calling methods on NULL pointers wherever possible.
The trick we use to allow this is undefined behaviour and is not liked by LLVM. We should stop using it but it has the potential to break to many things for a minor release.
This commit is contained in:
parent
402a1bb010
commit
6935ce2956
@ -197,6 +197,9 @@ class CoreExport ServerConfig
|
||||
|
||||
ConfigTagList ConfTags(const std::string& tag);
|
||||
|
||||
/** An empty configuration tag. */
|
||||
ConfigTag* EmptyTag;
|
||||
|
||||
/** Error stream, contains error output from any failed configuration parsing.
|
||||
*/
|
||||
std::stringstream errstr;
|
||||
@ -527,6 +530,8 @@ class CoreExport ServerConfig
|
||||
*/
|
||||
ServerConfig();
|
||||
|
||||
~ServerConfig();
|
||||
|
||||
/** Get server ID as string with required leading zeroes
|
||||
*/
|
||||
const std::string& GetSID();
|
||||
|
@ -116,7 +116,7 @@ struct ModResult {
|
||||
* and numerical comparisons in preprocessor macros if they wish to support
|
||||
* multiple versions of InspIRCd in one file.
|
||||
*/
|
||||
#define INSPIRCD_VERSION_API 8
|
||||
#define INSPIRCD_VERSION_API 9
|
||||
|
||||
/**
|
||||
* This #define allows us to call a method in all
|
||||
|
@ -53,7 +53,7 @@ CmdResult CommandMotd::Handle (const std::vector<std::string>& parameters, User
|
||||
if (parameters.size() > 0 && parameters[0] != ServerInstance->Config->ServerName)
|
||||
return CMD_SUCCESS;
|
||||
|
||||
ConfigTag* tag = NULL;
|
||||
ConfigTag* tag = ServerInstance->Config->EmptyTag;
|
||||
if (IS_LOCAL(user))
|
||||
tag = user->GetClass()->config;
|
||||
std::string motd_name = tag->getString("motd", "motd");
|
||||
|
@ -51,7 +51,7 @@ CmdResult CommandRules::Handle (const std::vector<std::string>& parameters, User
|
||||
if (parameters.size() > 0 && parameters[0] != ServerInstance->Config->ServerName)
|
||||
return CMD_SUCCESS;
|
||||
|
||||
ConfigTag* tag = NULL;
|
||||
ConfigTag* tag = ServerInstance->Config->EmptyTag;
|
||||
if (IS_LOCAL(user))
|
||||
tag = user->GetClass()->config;
|
||||
std::string rules_name = tag->getString("rules", "rules");
|
||||
|
@ -48,6 +48,14 @@ ServerConfig::ServerConfig()
|
||||
OperMaxChans = 30;
|
||||
c_ipv4_range = 32;
|
||||
c_ipv6_range = 128;
|
||||
|
||||
std::vector<KeyVal>* items;
|
||||
EmptyTag = ConfigTag::create("empty", "<auto>", 0, items);
|
||||
}
|
||||
|
||||
ServerConfig::~ServerConfig()
|
||||
{
|
||||
delete EmptyTag;
|
||||
}
|
||||
|
||||
void ServerConfig::Update005()
|
||||
@ -888,7 +896,7 @@ ConfigTag* ServerConfig::ConfValue(const std::string &tag)
|
||||
{
|
||||
ConfigTagList found = config_data.equal_range(tag);
|
||||
if (found.first == found.second)
|
||||
return NULL;
|
||||
return EmptyTag;
|
||||
ConfigTag* rv = found.first->second;
|
||||
found.first++;
|
||||
if (found.first != found.second)
|
||||
|
Loading…
x
Reference in New Issue
Block a user