[LLVMbugs] [Bug 6699] New: false positive memory leak in C arrays with CoreFoundation
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Wed Mar 24 20:21:06 PDT 2010
http://llvm.org/bugs/show_bug.cgi?id=6699
Summary: false positive memory leak in C arrays with
CoreFoundation
Product: clang
Version: trunk
Platform: Macintosh
OS/Version: MacOS X
Status: NEW
Severity: normal
Priority: P
Component: Static Analyzer
AssignedTo: kremenek at apple.com
ReportedBy: darkshadow at nightproductions.net
CC: llvmbugs at cs.uiuc.edu
The static analyzer is reporting a false memory leak when assigning a
CoreFoundation object to a C style array inside of an if statement.
#include <CoreFoundation/CoreFoundation.h>
int main( int argc, const char *argv[] )
{
CFStringRef keys[4];
CFTypeRef values[4];
CFDictionaryRef h = NULL;
double num = 0.7;
keys[0] = CFSTR("One");
keys[1] = CFSTR("Two");
keys[2] = CFSTR("Three");
values[0] = values[1] = CFNumberCreate( kCFAllocatorDefault,
kCFNumberDoubleType, &num );
num = 1.25;
values[2] = CFNumberCreate( kCFAllocatorDefault, kCFNumberDoubleType, &num
);
if ( argc > 1 ) {
int numArgs = 4;
keys[3] = CFSTR("Four");
/*Following line is flagged as object created */
values[3] = CFNumberCreate( kCFAllocatorDefault, kCFNumberIntType,
&numArgs );
h = CFDictionaryCreate( kCFAllocatorDefault, (const void **)keys,
(const void **)values, 4, &kCFCopyStringDictionaryKeyCallBacks,
&kCFTypeDictionaryValueCallBacks );
} else {
keys[3] = NULL;
values[3] = NULL;
h = CFDictionaryCreate( kCFAllocatorDefault, (const void **)keys,
(const void **)values, 3, &kCFCopyStringDictionaryKeyCallBacks,
&kCFTypeDictionaryValueCallBacks );
}
CFShow( h );
CFRelease( h );
CFRelease( values[0] );
CFRelease( values[2] );
if ( values[3] ) /* Following line is falsely reporting a leak of above
object */
CFRelease( values[3] );
return 0;
}
--
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