Your method sometimes returns an instance while keeping count +1, and you most likely don't release it in the rest of your code. You return with saving count +1 if SecItemCopyMatching is called, but if publicKey is set, your function returns a value with saving count + -0, which is bad.
You need to make sure that you always return with the same save account. In this case, I would do:
} else { publicKeyReference = publicKey; CFRetain(publicKeyReference); }
Then, each caller of your method must verify the CFRelease value ... but this violates the get rule (it should return the value count + -0), so it might be nice to rename the method.
Darkdust
source share