Author: janderwald
Date: Tue May 23 23:27:27 2006
New Revision: 21990
URL:
http://svn.reactos.ru/svn/reactos?rev=21990&view=rev
Log:
prevent ncpa from crashing when no component is selected. patch & bug report by
ThePhysicist (bug 1519)
Modified:
trunk/reactos/dll/cpl/ncpa/ncpa.c
Modified: trunk/reactos/dll/cpl/ncpa/ncpa.c
URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/dll/cpl/ncpa/ncpa.c?rev=219…
==============================================================================
--- trunk/reactos/dll/cpl/ncpa/ncpa.c (original)
+++ trunk/reactos/dll/cpl/ncpa/ncpa.c Tue May 23 23:27:27 2006
@@ -263,11 +263,11 @@
SetDlgItemText(hwndDlg,IDC_NETCARDNAME,tpszDisplayName);
EnableWindow(GetDlgItem(hwndDlg,IDC_CONFIGURE),FALSE);
-
SetWindowLongPtr(hwndDlg,GWL_USERDATA,(DWORD_PTR)lParam);
//SetDlgItemTextA(hwndDlg,IDC_NETCARDNAME,Info[pPage->lParam].Description);
EnumRegKeys(NICPropertyProtocolCallback,hwndDlg,HKEY_LOCAL_MACHINE,_T("System\\CurrentControlSet\\Control\\Network\\{4D36E975-E325-11CE-BFC1-08002BE10318}"));
+ SendDlgItemMessage(hwndDlg, IDC_COMPONENTSLIST, LB_SETCURSEL, 0, 0);
}
break;
case WM_COMMAND:
@@ -302,14 +302,16 @@
// drop though
case IDC_PROPERTIES:
{
- TCHAR *tpszSubKey;
+ TCHAR *tpszSubKey = NULL;
TCHAR tpszNDIKey[MAX_PATH];
TCHAR tpszClsIDText[MAX_PATH];
TCHAR *tpszTCPIPClsID = _T("{A907657F-6FDF-11D0-8EFB-00C04FD912B2}");
HKEY hNDIKey;
DWORD dwType,dwSize;
HWND hListBox = GetDlgItem(hwndDlg,IDC_COMPONENTSLIST);
- tpszSubKey =
(TCHAR*)SendMessage(hListBox,LB_GETITEMDATA,SendMessage(hListBox,LB_GETCURSEL,0,0),0);
+ int iListBoxIndex = SendMessage(hListBox,LB_GETCURSEL,0,0);
+ if(iListBoxIndex != LB_ERR)
+ tpszSubKey = (TCHAR*)SendMessage(hListBox,LB_GETITEMDATA,iListBoxIndex,0);
if(!tpszSubKey)
break;
_stprintf(tpszNDIKey,_T("%s\\Ndi"),tpszSubKey);
@@ -598,9 +600,8 @@
EnableWindow(GetDlgItem(hwndDlg,IDC_ADD),FALSE);
EnableWindow(GetDlgItem(hwndDlg,IDC_REMOVE),FALSE);
+ EnumAdapters(hwndDlg);
SendDlgItemMessage(hwndDlg,IDC_NETCARDLIST,LB_SETCURSEL,0,0);
-
- EnumAdapters(hwndDlg);
}
break;