Re: Crash after [NSData dataWithData:(NSMutableData *)]
Re: Crash after [NSData dataWithData:(NSMutableData *)]
- Subject: Re: Crash after [NSData dataWithData:(NSMutableData *)]
- From: James Housley <email@hidden>
- Date: Tue, 26 Jul 2005 09:45:26 -0400
email@hidden wrote:
Omitting a great deal of intervening code for brevity, my program is
doing this:
NSMutableData * sourceData = [NSMutableData dataWithCapacity:
[theAnnotatedData length]];
// append some bytes to sourceData
NSData * destinationData = [NSData dataWithData:aData];
[sourceData release];
destinationData is actually a member of another class, and the NSData
dataWithData: line in in that class.
The program crashes with EXC_BAD_ACCESS in NSPopAutoreleasePool/
objc_msgSend_rtp if I release sourceData. If I comment out the last
line, no crash.
There is plenty of other stuff I could be doing wrong (e.g., being a
hopeless noob), but as a sanity check, am I supposed to be retaining
something or not using NSData dataWithData: from an instance of
NSMutableData?
Since you are using dataWithData and dataWithCapacity you are creating
temporary objects and shouldn't release them. If you were using
[[NSMutableData alloc] initWithCapacity:... then you need to release it.
Jim
--
/"\ ASCII Ribbon Campaign .
\ / - NO HTML/RTF in e-mail .
X - NO Word docs in e-mail .
/ \ -----------------------------------------------------------------
email@hidden http://www.FreeBSD.org The Power to Serve
email@hidden http://www.TheHousleys.net
---------------------------------------------------------------------
Studies show that 1 out of every 4 Americans suffer some form of
mental illness. So look at your three best friends, if they
are okay it is YOU!
Attachment:
smime.p7s
Description: S/MIME Cryptographic Signature
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden