From 1c9009e9b220242a088fa442bde462a6decb7242 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20Ust=C3=BB=C5=BEanin?= Date: Thu, 9 Sep 2021 13:05:50 +0300 Subject: [PATCH] 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 --- PowerEditor/src/winmain.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/PowerEditor/src/winmain.cpp b/PowerEditor/src/winmain.cpp index 3c2e6e8dc..2936a0c6c 100644 --- a/PowerEditor/src/winmain.cpp +++ b/PowerEditor/src/winmain.cpp @@ -20,6 +20,7 @@ #include "MiniDumper.h" //Write dump files #include "verifySignedfile.h" #include "NppDarkMode.h" +#include typedef std::vector 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_plus = *upNotepadWindow.get(); generic_string updaterDir = nppParameters.getNppPath(); updaterDir += TEXT("\\updater\\");