aboutsummaryrefslogtreecommitdiff
path: root/src/configreader.cpp
diff options
context:
space:
mode:
authorGravatar Sadie Powell2023-07-12 15:25:13 +0100
committerGravatar Sadie Powell2023-07-12 15:25:13 +0100
commit4ce688f4708156d02fc665dfc5f59a650972a6f9 (patch)
tree0ea024b87d59dd458b96d35ed9bd6c5c334577ee /src/configreader.cpp
parentFix sending the wrong message when a user requests stats. (diff)
Fix some issues with ReadFile.
- Fix invalidating invoking undefined behaviour when a file is not already cached. - Fix memory corruption caused by assigning a bool to a string.
Diffstat (limited to 'src/configreader.cpp')
-rw-r--r--src/configreader.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/configreader.cpp b/src/configreader.cpp
index e71c22f59..110dc9172 100644
--- a/src/configreader.cpp
+++ b/src/configreader.cpp
@@ -96,10 +96,12 @@ ServerConfig::ServerConfig()
ServerConfig::ReadResult ServerConfig::ReadFile(const std::string& file, bool invalidate)
{
auto contents = filecontents.find(file);
- if (invalidate)
+ if (contents != filecontents.end())
+ {
+ if (!invalidate)
+ return ReadResult(contents->second, {});
filecontents.erase(contents);
- else if (contents != filecontents.end())
- return ReadResult(contents->second, {});
+ }
bool executable = false;
std::string name = file;
@@ -110,7 +112,7 @@ ServerConfig::ReadResult ServerConfig::ReadFile(const std::string& file, bool in
if (source != filesources.end())
{
name = source->first;
- path = source->second.second;
+ path = source->second.first;
executable = source->second.second;
}