[LLVMbugs] [Bug 2983] New: Missing memory leak report in -init methods that do not return self.

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Thu Oct 30 02:08:00 PDT 2008


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: unassignedbugs at nondot.org
        ReportedBy: devlists at shadowlab.org
                CC: llvmbugs at cs.uiuc.edu


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.



More information about the llvm-bugs mailing list