1*1a17032bSKristof Umann 2*1a17032bSKristof Umann 3*1a17032bSKristof Umannvoid test() { 4*1a17032bSKristof Umann unsigned int *ptr = 0; 5*1a17032bSKristof Umann UInt32 length; 6*1a17032bSKristof Umann 7*1a17032bSKristof Umann SecKeychainItemFreeContent(ptr, &length); 8*1a17032bSKristof Umann // warn: trying to free data which has not been allocated 9*1a17032bSKristof Umann} 10*1a17032bSKristof Umann 11*1a17032bSKristof Umannvoid test() { 12*1a17032bSKristof Umann unsigned int *ptr = 0; 13*1a17032bSKristof Umann UInt32 *length = 0; 14*1a17032bSKristof Umann void *outData; 15*1a17032bSKristof Umann 16*1a17032bSKristof Umann OSStatus st = 17*1a17032bSKristof Umann SecKeychainItemCopyContent(2, ptr, ptr, length, outData); 18*1a17032bSKristof Umann // warn: data is not released 19*1a17032bSKristof Umann} 20*1a17032bSKristof Umann 21*1a17032bSKristof Umannvoid test() { 22*1a17032bSKristof Umann unsigned int *ptr = 0; 23*1a17032bSKristof Umann UInt32 *length = 0; 24*1a17032bSKristof Umann void *outData; 25*1a17032bSKristof Umann 26*1a17032bSKristof Umann OSStatus st = 27*1a17032bSKristof Umann SecKeychainItemCopyContent(2, ptr, ptr, length, &outData); 28*1a17032bSKristof Umann 29*1a17032bSKristof Umann SecKeychainItemFreeContent(ptr, outData); 30*1a17032bSKristof Umann // warn: only call free if a non-NULL buffer was returned 31*1a17032bSKristof Umann} 32*1a17032bSKristof Umann 33*1a17032bSKristof Umannvoid test() { 34*1a17032bSKristof Umann unsigned int *ptr = 0; 35*1a17032bSKristof Umann UInt32 *length = 0; 36*1a17032bSKristof Umann void *outData; 37*1a17032bSKristof Umann 38*1a17032bSKristof Umann OSStatus st = 39*1a17032bSKristof Umann SecKeychainItemCopyContent(2, ptr, ptr, length, &outData); 40*1a17032bSKristof Umann 41*1a17032bSKristof Umann st = SecKeychainItemCopyContent(2, ptr, ptr, length, &outData); 42*1a17032bSKristof Umann // warn: release data before another call to the allocator 43*1a17032bSKristof Umann 44*1a17032bSKristof Umann if (st == noErr) 45*1a17032bSKristof Umann SecKeychainItemFreeContent(ptr, outData); 46*1a17032bSKristof Umann} 47*1a17032bSKristof Umann 48*1a17032bSKristof Umannvoid test() { 49*1a17032bSKristof Umann SecKeychainItemRef itemRef = 0; 50*1a17032bSKristof Umann SecKeychainAttributeInfo *info = 0; 51*1a17032bSKristof Umann SecItemClass *itemClass = 0; 52*1a17032bSKristof Umann SecKeychainAttributeList *attrList = 0; 53*1a17032bSKristof Umann UInt32 *length = 0; 54*1a17032bSKristof Umann void *outData = 0; 55*1a17032bSKristof Umann 56*1a17032bSKristof Umann OSStatus st = 57*1a17032bSKristof Umann SecKeychainItemCopyAttributesAndData(itemRef, info, 58*1a17032bSKristof Umann itemClass, &attrList, 59*1a17032bSKristof Umann length, &outData); 60*1a17032bSKristof Umann 61*1a17032bSKristof Umann SecKeychainItemFreeContent(attrList, outData); 62*1a17032bSKristof Umann // warn: deallocator doesn't match the allocator 63*1a17032bSKristof Umann} 64*1a17032bSKristof Umann 65