Fix a crash (regression) due to "new-less" of NppParameters
The commit 'Make NppParameters singleton "new-less"' make NppParameters instantiate in the stack instead of allocating in the heap:
3dbb2c4b8e
It makes Notepad++ crash:
https://community.notepad-plus-plus.org/topic/18316/notepad-7-8-release-candidate-3/4
The crash is on following code:
vector<MacroShortcut> & vShortcuts = NppParameters::getInstance().getMacroList();
size_t nbItems = vShortcuts.size();
for (size_t itemIndex2 = 0; itemIndex2 < nbItems; ++itemIndex2)
{
...
vShortcuts.size() here return a random large number, which makes crash.
The explanation about vector::size() unexpected behaviour:
https://stackoverflow.com/questions/30548944/c-vector-size-is-wrong-and-higher-than-the-number-of-elements
Obviously the stack size is not large enough to contain NppParameters singleton in 64 bits.
This commit is contained in:
parent
7651d703a9
commit
10f6ff6c1f
@ -1293,8 +1293,8 @@ class NppParameters final
|
||||
{
|
||||
public:
|
||||
static NppParameters& getInstance() {
|
||||
static NppParameters instance;
|
||||
return instance;
|
||||
static NppParameters* instance = new NppParameters;
|
||||
return *instance;
|
||||
};
|
||||
static LangType getLangIDFromStr(const TCHAR *langName);
|
||||
static generic_string getLocPathFromStr(const generic_string & localizationCode);
|
||||
@ -1658,6 +1658,7 @@ private:
|
||||
NppParameters(NppParameters&&) = delete;
|
||||
NppParameters& operator=(NppParameters&&) = delete;
|
||||
|
||||
|
||||
TiXmlDocument *_pXmlDoc = nullptr;
|
||||
TiXmlDocument *_pXmlUserDoc = nullptr;
|
||||
TiXmlDocument *_pXmlUserStylerDoc = nullptr;
|
||||
|
Loading…
Reference in New Issue
Block a user