size the buffer dynamically to avoid potentially overflowing it

svn path=/trunk/; revision=23438
This commit is contained in:
Ged Murphy 2006-08-03 19:06:12 +00:00
parent c6b0db6688
commit 728a261829

View file

@ -466,14 +466,25 @@ DisplayTCPIPProperties(HWND hParent, IP_ADAPTER_INFO *pInfo)
PROPSHEETHEADERW psh;
INITCOMMONCONTROLSEX cce;
TCPIP_PROPERTIES_DATA DlgData;
TCHAR tpszCaption[MAX_PATH];
HWND hListBox = GetDlgItem(hParent,IDC_COMPONENTSLIST);
int iListBoxIndex = (int) SendMessage(hListBox,LB_GETCURSEL,0,0);
LPTSTR tpszCaption = NULL;
INT StrLen;
HWND hListBox = GetDlgItem(hParent, IDC_COMPONENTSLIST);
int iListBoxIndex = (int) SendMessage(hListBox, LB_GETCURSEL, 0, 0);
if(iListBoxIndex != LB_ERR)
SendMessage(hListBox,LB_GETTEXT,iListBoxIndex,(LPARAM)tpszCaption);
else
_stprintf(tpszCaption,_T("[ERROR]"));
_tcscat(tpszCaption,_T(" Properties"));
{
StrLen = SendMessage(hListBox, LB_GETTEXTLEN, iListBoxIndex, 0);
if (StrLen != LB_ERR)
{
TCHAR suffix[] = _T(" Properties");
INT HeapSize = ((StrLen + 1) + (_tcslen(suffix) + 1)) * sizeof(TCHAR);
tpszCaption = (LPTSTR)HeapAlloc(GetProcessHeap(), 0, HeapSize);
SendMessage(hListBox, LB_GETTEXT, iListBoxIndex, (LPARAM)tpszCaption);
_tcscat(tpszCaption, suffix);
}
}
if (! LoadDataFromInfo(&DlgData, pInfo))
{