[cfe-commits] r50219 - /cfe/trunk/test/Analysis-Apple/NSString.m

Ted Kremenek kremenek at apple.com
Thu Apr 24 11:39:32 PDT 2008


It's a leak because its an extra reference count.  The caller of f7 is  
expected to either get an owning or non-owning reference, not an  
owning reference where they need to call CFRelease twice.  It's a  
heuristics, but it's an enforcement of the CF ownership model.

On Apr 24, 2008, at 11:39 AM, Fariborz Jahanian wrote:

>
> On Apr 24, 2008, at 11:17 AM, Ted Kremenek wrote:
>
>>
>> +
>> +NSString* f7(NSString* s1, NSString* s2, NSString* s3) {
>> +
>> +  NSString* s4 = CFStringCreateWithFormat(kCFAllocatorDefault, NULL,
>> +                                          L"%@ %@ (%@)",
>> +                                          s1, s2, s3);
>> +
>> +  CFRetain(s4);
>> +  return s4; // expected-warning{{leak}}
>
> Why does this constitute a leak? If caller releases it, everything  
> would be fine.
>
> - Fariborz
>
>>
>> +}
>>
>>
>> _______________________________________________
>> cfe-commits mailing list
>> cfe-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>




More information about the cfe-commits mailing list