Re: Static Analyzer and Core Foundation
Re: Static Analyzer and Core Foundation
- Subject: Re: Static Analyzer and Core Foundation
- From: Steve Cronin <email@hidden>
- Date: Fri, 18 Sep 2009 18:39:53 -0500
Luke;
OK thank-you for that answer to question 2!
Any thoughts on question 1?
Steve
On Sep 18, 2009, at 6:36 PM, Luke the Hiesterman wrote:
Line 44 creates 2 objects, one goes into the dictRef, the other is
not assigned to a variable, but is used only as the second argument
to MDItemCopyAttributes. The object that you create inside that call
is never released.
Luke
On Sep 18, 2009, at 4:33 PM, Steve Cronin wrote:
Folks;
Alert - potential boneheaded-ness lies ahead - please be gentle.
I'll be the first to admit that I'm much happier in ObjC than C…
I thought I would try static analysis and see what turned up.
On the whole I must say I'm pleased but this one has me questioning
my basic understanding
if (![[NSFileManager defaultManager] fileExistsAtPath:thisPath]) {
…
41 } else {
42 MDItemRef mdi = MDItemCreate( nil, (CFStringRef)thisPath );
43 if ( mdi != nil ) {
44 CFDictionaryRef dictRef = MDItemCopyAttributes( mdi,
MDItemCopyAttributeNames(mdi));
…
CFRelease(dictRef);
} else {
… handle error
}
}
Static Analysis tells me I have a potential leak of object
allocated on line 44 -- that's all.
My questions are:
1) Why is there not a warning for the object allocated on line 42 -
mdi ?
2) Why is the CFRelease(dictRef) not sufficient?
Thank you for you patience!
Steve_______________________________________________
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
_______________________________________________
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