Re: EXC_BAD_ACCESS in NSData
Re: EXC_BAD_ACCESS in NSData
- Subject: Re: EXC_BAD_ACCESS in NSData
- From: Jens Alfke <email@hidden>
- Date: Mon, 26 May 2014 15:06:25 -0700
On May 26, 2014, at 6:02 AM, Pax <email@hidden> wrote:
> When this gets run, I get EXC_BAD_ACCESS code = 2 here. I'm demonstrably reading less data than the file contains, and I've been able to read through the file successfully up to this point. Please could someone suggest to me what might be going wrong here?
Use the debugger to look at the values of the relevant variables, especially dataSize.
Since the result is a crash instead of an exception, the NSRange you create is valid; so I assume it’s just larger than your buffer so the copy runs off the end into unmapped address space.
Also, what exactly is the type of ‘bytes’? If it’s a pointer to a malloced buffer, you shouldn’t be passing its address, rather its value, otherwise you’re going to copy into the stack and blow up.
—Jens
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden