From 4ce688f4708156d02fc665dfc5f59a650972a6f9 Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Wed, 12 Jul 2023 15:25:13 +0100 Subject: 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. --- src/configreader.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/configreader.cpp') 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; } -- cgit v1.3.1-10-gc9f91