Skip to content

-checker-cfref doesn't take the @finally block into account #4330

@llvmbot

Description

@llvmbot
Bugzilla Link 3958
Version unspecified
OS All
Reporter LLVM Bugzilla Contributor
CC @tkremenek

Extended Description

When some objects are allocated before or inside a @​try block,
-checker-cfref doesn't "see" the code in the @​finally block which deallocates these objects.

Test case, reporting false positives:

// RUN: clang-cc -analyze -checker-cfref -verify %s

#import <Foundation/Foundation.h>

void f1()
{
int i = 1;
while(i-- > 0)
{
NSAutoreleasePool *innerPool = [[NSAutoreleasePool alloc] init]; // no-warning. Currently produces: Potential leak of object allocated on line 10 and stored into 'innerPool'
NSArray *array = nil;

@&#8203;try {
  array = [[NSMutableArray alloc] init]; // no-warning. Currently produces: Potential leak of object allocated on line 14 and stored into 'array'
  break;
}
@&#8203;catch (NSException * e) {}
@&#8203;finally {
  [array release];
  [innerPool drain];
}

}
}

Clang revision: 68443

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions