mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-12-07 19:22:17 +01:00
Fix non-const mapMultiArgs[] access after init.
Swap mapMultiArgs for a const-reference to a _mapMultiArgs which is only accessed in util.cpp
This commit is contained in:
18
src/util.cpp
18
src/util.cpp
@@ -103,7 +103,8 @@ const char * const BITCOIN_CONF_FILENAME = "bitcoin.conf";
|
||||
const char * const BITCOIN_PID_FILENAME = "bitcoind.pid";
|
||||
|
||||
map<string, string> mapArgs;
|
||||
map<string, vector<string> > mapMultiArgs;
|
||||
static map<string, vector<string> > _mapMultiArgs;
|
||||
const map<string, vector<string> >& mapMultiArgs = _mapMultiArgs;
|
||||
bool fDebug = false;
|
||||
bool fPrintToConsole = false;
|
||||
bool fPrintToDebugLog = true;
|
||||
@@ -238,9 +239,12 @@ bool LogAcceptCategory(const char* category)
|
||||
static boost::thread_specific_ptr<set<string> > ptrCategory;
|
||||
if (ptrCategory.get() == NULL)
|
||||
{
|
||||
const vector<string>& categories = mapMultiArgs["-debug"];
|
||||
ptrCategory.reset(new set<string>(categories.begin(), categories.end()));
|
||||
// thread_specific_ptr automatically deletes the set when the thread ends.
|
||||
if (mapMultiArgs.count("-debug")) {
|
||||
const vector<string>& categories = mapMultiArgs.at("-debug");
|
||||
ptrCategory.reset(new set<string>(categories.begin(), categories.end()));
|
||||
// thread_specific_ptr automatically deletes the set when the thread ends.
|
||||
} else
|
||||
ptrCategory.reset(new set<string>());
|
||||
}
|
||||
const set<string>& setCategories = *ptrCategory.get();
|
||||
|
||||
@@ -343,7 +347,7 @@ static void InterpretNegativeSetting(std::string& strKey, std::string& strValue)
|
||||
void ParseParameters(int argc, const char* const argv[])
|
||||
{
|
||||
mapArgs.clear();
|
||||
mapMultiArgs.clear();
|
||||
_mapMultiArgs.clear();
|
||||
|
||||
for (int i = 1; i < argc; i++)
|
||||
{
|
||||
@@ -371,7 +375,7 @@ void ParseParameters(int argc, const char* const argv[])
|
||||
InterpretNegativeSetting(str, strValue);
|
||||
|
||||
mapArgs[str] = strValue;
|
||||
mapMultiArgs[str].push_back(strValue);
|
||||
_mapMultiArgs[str].push_back(strValue);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -543,7 +547,7 @@ void ReadConfigFile(const std::string& confPath)
|
||||
InterpretNegativeSetting(strKey, strValue);
|
||||
if (mapArgs.count(strKey) == 0)
|
||||
mapArgs[strKey] = strValue;
|
||||
mapMultiArgs[strKey].push_back(strValue);
|
||||
_mapMultiArgs[strKey].push_back(strValue);
|
||||
}
|
||||
// If datadir is changed in .conf file:
|
||||
ClearDatadirCache();
|
||||
|
||||
Reference in New Issue
Block a user