0
它写在VC6的功能。堆损坏之后检测从VC6项目升级到VC9
bool CProductionTestDlg::GetVariables(CString strFilename, CMapStringToOb *cVariableMap)
{
int iMaxEntryLen = 1000;
//char rgbEntryNames[1000]; //previous
char *rgbEntryNames = (char*)malloc(iMaxEntryLen * sizeof(int)); //Now
CString strEntryName = "";
CString strEntryValue = "";
UINT uiSeperator = 0;
ULONG dwRetCode, dwSizeOfReturn;
dwSizeOfReturn = GetPrivateProfileString(cszVariables,
NULL,
"",
rgbEntryNames,
iMaxEntryLen,
strFilename);
while (uiSeperator < dwSizeOfReturn)
{
strEntryName.Format("%s", &rgbEntryNames[uiSeperator]);
uiSeperator += strEntryName.GetLength() + 1;
CString *strValue = new CString();
dwRetCode = GetPrivateProfileString(cszVariables,
strEntryName,
"",
strEntryValue.GetBufferSetLength(strEntryValue.GetLength()),
iMaxEntryLen,
strFilename);
strValue->Format("%s", strEntryValue);
cVariableMap->SetAt(strEntryName, (CObject*)strValue);
}
return true;
}
现在我正确升级它vs08.The项目构建,但是当我打开exe文件抛出异常
* 堆损坏测出* CRT检测到应用程序堆结束后写信给内存缓冲。
当我调试我的应用程序时,控件在返回true后在0123行转到dbgheap.c。
我觉得缓冲rgbEntryNames太小 – Jeeva 2012-07-12 05:50:47
好吧我尝试....... – vikky 2012-07-12 05:52:56
我试过了,但问题仍然是一样的...... – vikky 2012-07-12 05:53:37