Re: verify input parameter of init method and return nil before invoke [super init]
Re: verify input parameter of init method and return nil before invoke [super init]
- Subject: Re: verify input parameter of init method and return nil before invoke [super init]
- From: Quincey Morris <email@hidden>
- Date: Tue, 29 Jan 2013 09:46:57 -0800
On Jan 29, 2013, at 09:07 , Jens Alfke <email@hidden> wrote:
> Actually this is fine, because free(NULL) is legal. A better example would be a dealloc that calls CFRelease, because [for some reason] CFRelease does crash if passed NULL.
Yes, no one is ever going to hire me for my deep Unix knowledge.
> I would argue that the bug here is in the dealloc method. Dealloc methods should be written to run correctly if the init method was not called or had to back out partway through. (And this is, I think, one of the reasons why +alloc zeroes out the bytes of an object.)
I would agree. However, it would be prudent to assume to there are some dealloc's out there (written by other people, of course) that aren't written defensively against incomplete ivar initialization, and a lot more out there that aren't written defensively against the superclass initialization never having been called at all.
_______________________________________________
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