Fix a crash bug due to eventual disordered notifications sent to plugins

The Access Violation while closing Notepad++:
https://github.com/notepad-plus-plus/notepad-plus-plus/issues/3961
could be due to SCN_UPDATEUI sending after NPPN_SHUTDOWN, that makes
plugins treat SCN_UPDATEUI on the released handle.

To avoid such situation, once NPPN_SHUTDOWN has been sent, no more
message will be sent to plugin.

Fixes #3961, fixes #4021
This commit is contained in:
Don HO 2017-12-27 14:55:35 +01:00
parent b2c3e82ce7
commit 2390b19706
2 changed files with 5 additions and 0 deletions

View File

@ -564,6 +564,10 @@ void PluginsManager::runPluginCommand(const TCHAR *pluginName, int commandID)
void PluginsManager::notify(const SCNotification *notification)
{
if (_noMoreNotification) // this boolean should be enabled after NPPN_SHUTDOWN has been sent
return;
_noMoreNotification = notification->nmhdr.code == NPPN_SHUTDOWN;
for (size_t i = 0, len = _pluginInfos.size() ; i < len ; ++i)
{
if (_pluginInfos[i]->_hLib)

View File

@ -137,6 +137,7 @@ private:
bool _isDisabled = false;
IDAllocator _dynamicIDAlloc;
IDAllocator _markerAlloc;
bool _noMoreNotification = false;
void pluginCrashAlert(const TCHAR *pluginName, const TCHAR *funcSignature)
{