summaryrefslogtreecommitdiff
path: root/src/modules/options
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2015-05-10 17:50:05 +0000
committerGeorge Hazan <george.hazan@gmail.com>2015-05-10 17:50:05 +0000
commitfb2153343180082ffb144eb2585e20bcf25351eb (patch)
tree1a4afcac6cb3b76ebe5b9afe97b316f7a0a49bc0 /src/modules/options
parentfc64dc4c81080c920eacdfb2fc23b24a7fef2f02 (diff)
crash fix for wrongly defined option pages
git-svn-id: http://svn.miranda-ng.org/main/trunk@13511 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'src/modules/options')
-rw-r--r--src/modules/options/options.cpp18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/modules/options/options.cpp b/src/modules/options/options.cpp
index f9a79eaec9..f56d396fec 100644
--- a/src/modules/options/options.cpp
+++ b/src/modules/options/options.cpp
@@ -86,6 +86,7 @@ struct OptionsPageData : public MZeroedObject
pDialog = new COptionPageDialog(src->hInstance, (int)src->pszTemplate, src->pfnDlgProc, src->dwInitParam);
else
pDialog = src->pDialog;
+ assert(pDialog != NULL);
flags = src->flags;
hLangpack = src->hLangpack;
@@ -108,7 +109,7 @@ struct OptionsPageData : public MZeroedObject
~OptionsPageData()
{
- if (getHwnd() != NULL)
+ if (pDialog && getHwnd() != NULL)
DestroyWindow(getHwnd());
}
@@ -712,8 +713,13 @@ static void LoadOptionsModule(HWND hdlg, OptionsDlgData *dat, HINSTANCE hInst)
if (opi.pageCount == 0)
return;
- for (int i = 0; i < opi.pageCount; i++)
- dat->arOpd.insert(new OptionsPageData(&opi.odp[i]));
+ for (int i = 0; i < opi.pageCount; i++) {
+ OptionsPageData *opd = new OptionsPageData(&opi.odp[i]);
+ if (opd->pDialog == NULL) // smth went wrong
+ delete opd;
+ else
+ dat->arOpd.insert(opd);
+ }
FreeOptionsData(&opi);
PostMessage(hdlg, DM_REBUILDPAGETREE, 0, 0);
@@ -814,7 +820,11 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hdlg, UINT message, WPARAM wParam, L
OPTIONSDIALOGPAGE *odp = (OPTIONSDIALOGPAGE*)psh->ppsp;
for (UINT i = 0; i < psh->nPages; i++, odp++) {
- dat->arOpd.insert(new OptionsPageData(odp));
+ OptionsPageData *opd = new OptionsPageData(odp);
+ if (opd->pDialog == NULL) // smth went wrong
+ delete opd;
+ else
+ dat->arOpd.insert(opd);
if (!mir_tstrcmp(lastPage, odp->ptszTitle) && !mir_tstrcmp(lastGroup, odp->ptszGroup))
if ((ood->pszTab == NULL && dat->currentPage == -1) || !mir_tstrcmp(lastTab, odp->ptszTab))