Re: Strange Warning Message from the Analyzer?
Re: Strange Warning Message from the Analyzer?
- Subject: Re: Strange Warning Message from the Analyzer?
- From: Dave <email@hidden>
- Date: Tue, 09 Jun 2015 14:54:11 +0100
Hi,
> I would assume it’s because you aren’t checking the value of myBaseBufferPtr after malloc returns. It could be nil there. So then later is the first place you try to deref it (even though it’s now assigned to a new variable), so that’s the first place a nil deref can be checked. You need to protect the rest of the code from running if it’s nil up in your insertIndexes method.
>
I was just about to post as I figured it out, the thing is that malloc should never return NULL and I thought the analyzer knew that, I guess it’s safer to test anyway.
> BTW, I don’t want to start up the multiple returns discussion again, but if you really must do it that way, at least add some obvious comments on each one:
>
> if(blah)
> return; // *** WARNING! Early return! ***
>
> That way people scanning your code will know there’s danger ahead, and won’t spend hours trying to figure out why it never hits a breakpoint they might have added down past the early returns they didn’t see.
Yeah, it’s not finished yet, will comment it properly when I’ve finished it, that way I stand a chance of the comments matching the code,
BTW, I don’t want to start up the worthless comments discussion again,
But wrong comments are worthless comments!
Cheers
Dave
_______________________________________________
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