views:

281

answers:

1

I have the following function:

- (NSString *)urlEncodedValue {
NSString *result = (NSString *)CFURLCreateStringByAddingPercentEscapes(
       kCFAllocatorDefault, 
       (CFStringRef)self, 
       NULL, 
       CFSTR("?=&+/\r\n"), 
       kCFStringEncodingUTF8
);

return [result autorelease];

}

Why is Clang giving me the following complaints?

  • 1 Call to function 'CFURLCreateStringByAddingPercentEscapes' returns a Core Foundation object with a +1 retain count (owning reference)
  • 2 Object sent -autorelease message
  • 3 Object returned to caller as an owning reference (single retain count transferred to caller)
  • 4 Object over-autoreleased: object was sent -autorelease but the object has zero (locally visible) retain counts

To the best of my knowledge, this conforms to Apple's guidelines regarding memory management and object ownership. Do I have to explicitly release the object? This error has come up 19 times in my project, all under similar circumstances. What am I doing wrong?

+2  A: 

I've found the answer to my own question, posting it here if anyone else stumbles across the issue. I was using checker-0.198, checker-0.204 reports no such issue. Seems it was a temporary regression.