36 lines · plain
1// RUN: %clang_analyze_cc1 -triple x86_64-apple-darwin10 -analyzer-checker=osx.SecKeychainAPI -analyzer-output=text -verify %s2 3// This file is for testing enhanced diagnostics produced by the default SecKeychainAPI checker.4 5typedef unsigned int OSStatus;6typedef unsigned int SecKeychainAttributeList;7typedef unsigned int SecKeychainItemRef;8typedef unsigned int SecItemClass;9typedef unsigned int UInt32;10enum {11 noErr = 0,12 GenericError = 113};14OSStatus SecKeychainItemCopyContent (15 SecKeychainItemRef itemRef,16 SecItemClass *itemClass,17 SecKeychainAttributeList *attrList,18 UInt32 *length,19 void **outData20 );21 22void DellocWithCFStringCreate4(void) {23 unsigned int *ptr = 0;24 OSStatus st = 0;25 UInt32 length;26 char *bytes;27 char *x;28 st = SecKeychainItemCopyContent(2, ptr, ptr, &length, (void **)&bytes); // expected-note {{Data is allocated here}}29 x = bytes;30 if (st == noErr) // expected-note {{Assuming 'st' is equal to noErr}} // expected-note{{Taking true branch}}31 x = bytes;;32 33 length++; // expected-warning {{Allocated data is not released}} // expected-note{{Allocated data is not released}}34}35 36