From d7db433ed83362cd9b4da2ff6582962995f87c41 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sat, 8 Dec 2018 15:30:24 +0300 Subject: fix for a rare crash in Options - Plugins --- src/mir_app/src/newplugins.cpp | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/mir_app/src/newplugins.cpp b/src/mir_app/src/newplugins.cpp index 234ec3e4f2..7407b444b2 100644 --- a/src/mir_app/src/newplugins.cpp +++ b/src/mir_app/src/newplugins.cpp @@ -265,21 +265,23 @@ bool Plugin_UnloadDyn(pluginEntry *p) return true; CMPluginBase *ppb = p->m_pPlugin; - if (HINSTANCE hInst = ppb->getInst()) { - if (CallPluginEventHook(hInst, hOkToExitEvent, 0, 0) != 0) - return false; + if (ppb != nullptr) { + if (HINSTANCE hInst = ppb->getInst()) { + if (CallPluginEventHook(hInst, hOkToExitEvent, 0, 0) != 0) + return false; - KillModuleAccounts(hInst); - KillModuleSubclassing(hInst); + KillModuleAccounts(hInst); + KillModuleSubclassing(hInst); - CallPluginEventHook(hInst, hPreShutdownEvent, 0, 0); - CallPluginEventHook(hInst, hShutdownEvent, 0, 0); + CallPluginEventHook(hInst, hPreShutdownEvent, 0, 0); + CallPluginEventHook(hInst, hShutdownEvent, 0, 0); - KillModuleEventHooks(hInst); - KillModuleServices(hInst); - } + KillModuleEventHooks(hInst); + KillModuleServices(hInst); + } - NotifyFastHook(hevUnloadModule, (WPARAM)&ppb->getInfo(), (LPARAM)ppb->getInst()); + NotifyFastHook(hevUnloadModule, (WPARAM)&ppb->getInfo(), (LPARAM)ppb->getInst()); + } // mark default plugins to be loaded if (!p->bIsCore) -- cgit v1.2.3