Home | History | Annotate | Download | only in Analysis
      1 // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=osx.SecKeychainAPI -analyzer-store=region -analyzer-output=text -verify %s
      2 
      3 // This file is for testing enhanced diagnostics produced by the default SecKeychainAPI checker.
      4 
      5 typedef unsigned int OSStatus;
      6 typedef unsigned int SecKeychainAttributeList;
      7 typedef unsigned int SecKeychainItemRef;
      8 typedef unsigned int SecItemClass;
      9 typedef unsigned int UInt32;
     10 enum {
     11     noErr                      = 0,
     12     GenericError               = 1
     13 };
     14 OSStatus SecKeychainItemCopyContent (
     15                                      SecKeychainItemRef itemRef,
     16                                      SecItemClass *itemClass,
     17                                      SecKeychainAttributeList *attrList,
     18                                      UInt32 *length,
     19                                      void **outData
     20                                      );
     21 
     22 void DellocWithCFStringCreate4() {
     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