From 59a23f03860d345582243cdfcf1f4e1c52489d73 Mon Sep 17 00:00:00 2001 From: Don HO Date: Mon, 6 Jun 2016 09:56:36 +0200 Subject: [PATCH] Fix a crash issue due to CmdLineParams CmdLineParams object of the block "case COPYDATA_PARAMS" is always made by another instance of Notepad++, (located usually in C:\Program Files (x86)\Notepad++\) which is launched by NppShell.dll. If CmdLineParams structure is modified in the local instance, and file is opened via NppShell.dll, then crash happeds. --- PowerEditor/src/NppBigSwitch.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/PowerEditor/src/NppBigSwitch.cpp b/PowerEditor/src/NppBigSwitch.cpp index 85d60a6d5..d999c814b 100644 --- a/PowerEditor/src/NppBigSwitch.cpp +++ b/PowerEditor/src/NppBigSwitch.cpp @@ -529,8 +529,19 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa { case COPYDATA_PARAMS: { - CmdLineParams *cmdLineParam = (CmdLineParams *)pCopyData->lpData; - pNppParam->setCmdlineParam(*cmdLineParam); + CmdLineParams *cmdLineParam = (CmdLineParams *)pCopyData->lpData; // CmdLineParams object from another instance + auto cmdLineParamsSize = static_cast(pCopyData->cbData); // CmdLineParams size from another instance + if (sizeof(CmdLineParams) == cmdLineParamsSize) // make sure the structure is the same + { + pNppParam->setCmdlineParam(*cmdLineParam); + } + else + { +#ifdef DEBUG + printStr(TEXT("sizeof(CmdLineParams) != cmdLineParamsSize\rCmdLineParams is formed by an instance of another version,\rwhereas your CmdLineParams has been modified in this instance.")); +#endif + } + NppGUI nppGui = (NppGUI)pNppParam->getNppGUI(); nppGui._isCmdlineNosessionActivated = cmdLineParam->_isNoSession; break;