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 응용 프로그램이 힙의 종료 후 메모리에 쓴 감지 * DETECTED 예외를 발생 완충기.
내 응용 프로그램을 디버깅 할 때 컨트롤은 dbgheap.c 라인을 반환합니다. 2103은 true를 반환 한 후입니다.
나는 버퍼 rgbEntryNames가 너무 작다고 생각한다. – Jeeva
나는 시도한다. ....... – vikky
나는 시험했다. 그러나 문제는 같다. ...... – vikky