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.
This commit is contained in:
Don HO 2016-06-06 09:56:36 +02:00
parent 2c0b66da43
commit 59a23f0386

View File

@ -529,8 +529,19 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
{
case COPYDATA_PARAMS:
{
CmdLineParams *cmdLineParam = (CmdLineParams *)pCopyData->lpData;
CmdLineParams *cmdLineParam = (CmdLineParams *)pCopyData->lpData; // CmdLineParams object from another instance
auto cmdLineParamsSize = static_cast<size_t>(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;