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