Fix open file crash via open file dialog

Notepad_plus_Window was rather huge (megabytes). Now it's small (tens of kilobytes),
but to safeguard against future size increase move its allocation from the stack
into the heap.
By using smart pointer, this PR not only fix open file crash properly,
but also prevent stack from being corrupted in the future.

Fix #10454, close #10531
This commit is contained in:
Ivan Ustûžanin 2021-09-09 13:05:50 +03:00 committed by Don Ho
parent 495d202a43
commit 1c9009e9b2
1 changed files with 3 additions and 1 deletions

View File

@ -20,6 +20,7 @@
#include "MiniDumper.h" //Write dump files
#include "verifySignedfile.h"
#include "NppDarkMode.h"
#include <memory>
typedef std::vector<generic_string> ParamVector;
@ -609,7 +610,8 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE, PWSTR pCmdLine, int)
}
}
Notepad_plus_Window notepad_plus_plus;
auto upNotepadWindow = std::make_unique<Notepad_plus_Window>();
Notepad_plus_Window & notepad_plus_plus = *upNotepadWindow.get();
generic_string updaterDir = nppParameters.getNppPath();
updaterDir += TEXT("\\updater\\");