Fix race condition in ConfigWriter::EmitIdentifier

fixes #10538
This commit is contained in:
Gunnar Beutner 2015-11-04 19:05:47 +01:00
parent 09b2b054f5
commit a3fd33f8a1
1 changed files with 8 additions and 3 deletions

View File

@ -146,9 +146,14 @@ void ConfigWriter::EmitIndent(std::ostream& fp, int indentLevel)
void ConfigWriter::EmitIdentifier(std::ostream& fp, const String& identifier, bool inAssignment)
{
static std::set<String> keywords;
if (keywords.empty()) {
const std::vector<String>& vkeywords = GetKeywords();
std::copy(vkeywords.begin(), vkeywords.end(), std::inserter(keywords, keywords.begin()));
static boost::mutex mutex;
{
boost::mutex::scoped_lock lock(mutex);
if (keywords.empty()) {
const std::vector<String>& vkeywords = GetKeywords();
std::copy(vkeywords.begin(), vkeywords.end(), std::inserter(keywords, keywords.begin()));
}
}
if (keywords.find(identifier) != keywords.end()) {