Problem with InstallOptions "WMCommandProc"
Possibly a problem with WMCommandProc function in the InstallOptions DLL. This is the current function. A possible crash exists as nIdx is not checked for a value < 0 before it is used which would result in an invalid array index.
The modified version with the array bounds check,LRESULT WMCommandProc
(HWND hWnd, UINT id, HWND hwndCtl, UINT codeNotify) {
switch (codeNotify) {
caseBN_CLICKED:
{
int nIdx = FindControlIdx(id);
if (pFields***91;nIdx***93;.nType == FIELD_BROWSEBUTTON) {
int nParentIdx = pFields***91;nIdx***93;.nParentIdx;
switch(pFields***91;nParentIdx***93;.nType) {
caseFIELD_FILEREQUEST:
BrowseForFile(nParentIdx);
break;
caseFIELD_DIRREQUEST:
BrowseForFolder(nParentIdx);
break;
}
break;
} else if (pFields***91;nIdx***93;.nType == FIELD_LINK) {
ShellExecute(hMainWindow, NULL, pFields***91;nIdx***93;.pszState, NULL, NULL, SW_SHOWDEFAULT);
}
}
break;
}
return0;
}
End result, everything is super. I do wonder why I was getting an array index less than 0 but I was.LRESULT WMCommandProc
(HWND hWnd, UINT id, HWND hwndCtl, UINT codeNotify) {
switch (codeNotify) {
caseBN_CLICKED:
{
int nIdx = FindControlIdx(id);
// I only added the next two lines for some error
// checking
if (nIdx < 0)
break;
if (pFields***91;nIdx***93;.nType == FIELD_BROWSEBUTTON) {
int nParentIdx = pFields***91;nIdx***93;.nParentIdx;
switch(pFields***91;nParentIdx***93;.nType) {
caseFIELD_FILEREQUEST:
BrowseForFile(nParentIdx);
break;
caseFIELD_DIRREQUEST:
BrowseForFolder(nParentIdx);
break;
}
break;
} else if (pFields***91;nIdx***93;.nType == FIELD_LINK) {
ShellExecute(hMainWindow, NULL, pFields***91;nIdx***93;.pszState, NULL, NULL, SW_SHOWDEFAULT);
}
}
break;
}
return0;
}