CFDataGetBytes causes crash in socket callback
CFDataGetBytes causes crash in socket callback
- Subject: CFDataGetBytes causes crash in socket callback
- From: Liwei <email@hidden>
- Date: Thu, 2 Oct 2008 01:36:59 +0800
I have setup a socket for UDP using CFSocket and bound it to localhost.
However every time data is received it crashes when I try to copy out
the data for printing. The relevant callback function is this:
void receiveData(CFSocketRef socket, CFSocketCallBackType type,
CFDataRef address, const void *data, void *info){
UInt8 *databuf;
CFMutableDataRef localdata =
CFDataCreateMutableCopy(kCFAllocatorDefault, 0, data);
if(localdata != NULL){
CFDataAppendBytes(localdata, (UInt8 *)"", 1);
CFDataGetBytes(localdata,CFRangeMake(0, CFDataGetLength(localdata)), databuf);
printf("%s", databuf);
}
return;
}
It crashes at CFDataGetBytes with a EXEC_BAD_ACCESS
I think it worked in the past (its been some time since I fiddled with
this code) before I shuffled some stuff around. Anyone knows what the
problem might be?
_______________________________________________
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