Added validations for page index before using it.

This commit is contained in:
Adrian Thurston 1999-11-13 20:49:12 +00:00 committed by Alexandre Julliard
parent 2d06944f38
commit 7d487c914f
1 changed files with 33 additions and 14 deletions

View File

@ -1021,6 +1021,9 @@ static BOOL PROPSHEET_Back(HWND hwndDlg)
PropSheetInfo* psInfo = (PropSheetInfo*) GetPropA(hwndDlg,
PropSheetInfoStr);
if (psInfo->active_page <= 0)
return FALSE;
hdr.hwndFrom = hwndDlg;
hdr.code = PSN_WIZBACK;
@ -1053,6 +1056,9 @@ static BOOL PROPSHEET_Next(HWND hwndDlg)
PropSheetInfo* psInfo = (PropSheetInfo*) GetPropA(hwndDlg,
PropSheetInfoStr);
if (psInfo->active_page < 0 || psInfo->active_page == psInfo->nPages - 1)
return FALSE;
hdr.hwndFrom = hwndDlg;
hdr.code = PSN_WIZNEXT;
@ -1084,6 +1090,9 @@ static BOOL PROPSHEET_Finish(HWND hwndDlg)
PropSheetInfo* psInfo = (PropSheetInfo*) GetPropA(hwndDlg,
PropSheetInfoStr);
if (psInfo->active_page < 0)
return FALSE;
hdr.hwndFrom = hwndDlg;
hdr.code = PSN_WIZFINISH;
@ -1116,6 +1125,9 @@ static BOOL PROPSHEET_Apply(HWND hwndDlg)
PropSheetInfo* psInfo = (PropSheetInfo*) GetPropA(hwndDlg,
PropSheetInfoStr);
if (psInfo->active_page < 0)
return FALSE;
hdr.hwndFrom = hwndDlg;
/*
@ -1152,9 +1164,13 @@ static void PROPSHEET_Cancel(HWND hwndDlg)
{
PropSheetInfo* psInfo = (PropSheetInfo*) GetPropA(hwndDlg,
PropSheetInfoStr);
HWND hwndPage = psInfo->proppage[psInfo->active_page].hwndPage;
HWND hwndPage;
NMHDR hdr;
if (psInfo->active_page < 0)
return;
hwndPage = psInfo->proppage[psInfo->active_page].hwndPage;
hdr.hwndFrom = hwndDlg;
hdr.code = PSN_QUERYCANCEL;
@ -1178,9 +1194,13 @@ static void PROPSHEET_Help(HWND hwndDlg)
{
PropSheetInfo* psInfo = (PropSheetInfo*) GetPropA(hwndDlg,
PropSheetInfoStr);
HWND hwndPage = psInfo->proppage[psInfo->active_page].hwndPage;
HWND hwndPage;
NMHDR hdr;
if (psInfo->active_page < 0)
return;
hwndPage = psInfo->proppage[psInfo->active_page].hwndPage;
hdr.hwndFrom = hwndDlg;
hdr.code = PSN_HELP;
@ -1301,9 +1321,8 @@ static BOOL PROPSHEET_CanSetCurSel(HWND hwndDlg)
HWND hwndPage;
NMHDR hdr;
if (!psInfo)
return FALSE;
if (!psInfo || psInfo->active_page < 0)
return FALSE;
/*
* Notify the current page.
*/
@ -1328,6 +1347,9 @@ static BOOL PROPSHEET_SetCurSel(HWND hwndDlg,
HWND hwndHelp = GetDlgItem(hwndDlg, IDHELP);
NMHDR hdr;
if (psInfo->active_page < 0)
return FALSE;
hwndPage = psInfo->proppage[psInfo->active_page].hwndPage;
hdr.hwndFrom = hwndDlg;
@ -1335,14 +1357,12 @@ static BOOL PROPSHEET_SetCurSel(HWND hwndDlg,
* hpage takes precedence over index.
*/
if (hpage != NULL)
{
index = PROPSHEET_GetPageIndex(hpage, psInfo);
if (index == -1)
{
TRACE("Could not find page to remove!\n");
return FALSE;
}
if (index < 0 || index >= psInfo->nPages)
{
TRACE("Could not find page to select!\n");
return FALSE;
}
hwndPage = psInfo->proppage[index].hwndPage;
@ -1804,6 +1824,8 @@ PROPSHEET_DialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
HWND hwndTabCtrl = GetDlgItem(hwnd, IDC_TABCONTROL);
LPCPROPSHEETPAGEA ppshpage;
SetPropA(hwnd, PropSheetInfoStr, (HANDLE)psInfo);
/*
* Small icon in the title bar.
*/
@ -1868,9 +1890,6 @@ PROPSHEET_DialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
if (!(psInfo->ppshheader->dwFlags & PSH_WIZARD))
SendMessageA(hwndTabCtrl, TCM_SETCURSEL, psInfo->active_page, 0);
SetPropA(hwnd, PropSheetInfoStr, (HANDLE)psInfo);
if (!HIWORD(psInfo->ppshheader->pszCaption) &&
psInfo->ppshheader->hInstance)
{