title: HEAP CORRUPTION DETECTED after upgrade the project from vc6 to vc9
body: <p>The function which were written in vc6.</p>
  
  <pre><code>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 &lt; dwSizeOfReturn )
      {
          strEntryName.Format("%s", &amp;rgbEntryNames[uiSeperator]);
          uiSeperator += strEntryName.GetLength() + 1;
  
          CString *strValue = new CString();
          dwRetCode = GetPrivateProfileString(cszVariables,
                                              strEntryName,
                                              "",
                                              strEntryValue.GetBufferSetLength(strEntryValue.GetLength()),
                                              iMaxEntryLen,
                                              strFilename);
          strValue-&gt;Format("%s", strEntryValue);        
          cVariableMap-&gt;SetAt(strEntryName, (CObject*)strValue);
  
      }
  
      return true;
  }
  </code></pre>
  
  <p>Now I upgrade it on vs08.The project build correctly but when I open exe it throw an exception </p>
  
  <p>*<em>HEAP CORRUPTION DETECTED *</em> CRT Detected that the application wrote to memory after end of heap buffer.</p>
  
  <p>When I debug the my application the the control goes to <strong>dbgheap.c</strong> at line no 2103 after return true.</p>