http://llvm.org/bugs/show_bug.cgi?id=2983

           Summary: Missing memory leak report in -init methods that do not
                    return self.
           Product: clang
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Semantic Analyzer
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]
                CC: [email protected]


Generaly, an initializer returns self, but in some case, it may decide to
return something else (it's a common practice to return nil when something goes
wrong)

In these cases, 'self' must be release before the method returns else
it will leaks.
(http://www.cocoabuilder.com/archive/message/cocoa/2008/2/11/198549
)

for example:

- (id)initWithString:(NSString *)str {
        if (!str) {
                [self release];
                return nil; // analyzer does not report a leak, but it should
        }
        if (self = [super init]) {
                // do something with str
        }
        return self;
}


-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to