Irregular Exception

  • Thread starter Thread starter Manfred Huber
  • Start date Start date
M

Manfred Huber

Hello,

sometimes the source code below raises following exception:

HEAP[Test.exe]: HEAP: Free Heap block cda1788 modified at cda1880 after it
was freed

Unhandled exception at 0x77f65a58 in Test.exe: User breakpoint.

This exception is only raised a few times. Sometimes the code works without
that exception. The Debugger stops at the line "iReadByte =
lStream->ReadByte ();"

String* CDownload::DownloadEx(String *strUrl, String* strFileName,
System::Windows::Forms::Label* StatusLabel)

{

WebRequest* lRequest = HttpWebRequest::Create (strUrl);

HttpWebResponse* lResponse = (HttpWebResponse*)lRequest->GetResponse ();

System::IO::Stream* lStream = lResponse->GetResponseStream ();

int iReadByte = 0;

unsigned long lBytes = 0;

StringBuilder* lString = new StringBuilder();

iReadByte = lStream->ReadByte ();

if (iReadByte == -1)

{

return "";

}

do

{

lString->Append (Convert::ToChar (iReadByte));

iReadByte = lStream->ReadByte ();

} while (iReadByte != -1);

lStream->Close ();

return lString->ToString ();

}
 
Manfred said:
Hello,

sometimes the source code below raises following exception:

The problem is elsewhere in your code. Something is overwriting heap
control structures which eventually leads to this exception. Most likely,
you're modifying an object after it's been deleted or deleting an object
twice.

You might consider getting a tool such as BoundsChecker or Purify to help
find where your code is corrupting the heap.

-cd
 
Back
Top