• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: CFDataGetBytes causes crash in socket callback
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: CFDataGetBytes causes crash in socket callback


  • Subject: Re: CFDataGetBytes causes crash in socket callback
  • From: Frederick Cheung <email@hidden>
  • Date: Wed, 1 Oct 2008 18:51:20 +0100

CFDataGetBytes is expecting you to pass it a pointer to a buffer of sufficient size, but you are passing it an uninitialized pointer (databuf)

Fred

Sent from my iPhone

On 1 Oct 2008, at 18:36, Liwei <email@hidden> wrote:

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
_______________________________________________
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


  • Follow-Ups:
    • Re: CFDataGetBytes causes crash in socket callback
      • From: Liwei <email@hidden>
References: 
 >CFDataGetBytes causes crash in socket callback (From: Liwei <email@hidden>)

  • Prev by Date: CFDataGetBytes causes crash in socket callback
  • Next by Date: Re: CFDataGetBytes causes crash in socket callback
  • Previous by thread: CFDataGetBytes causes crash in socket callback
  • Next by thread: Re: CFDataGetBytes causes crash in socket callback
  • Index(es):
    • Date
    • Thread