blob: a78b114a00fb2c5dced35c01d41336ac50bb1558 [file] [log] [blame]
Anna Zaks98401112011-08-24 20:52:46 +00001// 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
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 = 1
13};
14OSStatus SecKeychainItemCopyContent (
15 SecKeychainItemRef itemRef,
16 SecItemClass *itemClass,
17 SecKeychainAttributeList *attrList,
18 UInt32 *length,
19 void **outData
20 );
21
22void 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