Re: Crash in CFReadStream Callback
Re: Crash in CFReadStream Callback
- Subject: Re: Crash in CFReadStream Callback
- From: Frederick Cheung <email@hidden>
- Date: Sat, 2 Apr 2005 23:03:52 +0200
Message: 1
Date: Sat, 02 Apr 2005 10:54:52 +0000
From: Trygve Inda <email@hidden>
Subject: Crash in CFReadStream Callback
To: <email@hidden>
Message-ID: <BE742A7C.33D05%email@hidden>
Content-Type: text/plain; charset="US-ASCII"
I have a CFReadStream pulling back a jpg file over HTTP.
In some cases I do not have a header to determine the size.
cfHeaderField = CFHTTPMessageCopyHeaderFieldValue (cfHeader,
CFSTR("Content-Length"));
In this situation I tried to allocate a buffer and keep increasing its
size
as bytes are returned...
bytesRead = CFReadStreamRead (stream, buffer, sizeof(buffer));
if (bytesRead > 0)
{
if (noHeaderSize)
{
SetPtrSize (dInfo->mBuffer, dInfo->mContentRead + bytesRead);
}
My guess is that there is a chance SetPtrSize will eventually fail
since it might be prevented from resizing the pointer by other blocks
of memory. Since you aren't checking MemError() to see if this is
happening you are writing into space and trashing stuff. I'd either use
realloc since that will move everything to a new location in that
scenario, or use CFMutableData.
Fred
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden