Below is my code, which used to work fine till iOS 9.
- (NSData *)encryptWithDataPublicKey:(NSString*)data keyTag:(NSString*)tag
{
SecKeyRef publicKey = N
In encryptData:withKeyRef:
you have an unbalanced CFRelease
at the end of the method. Nothing in that method retained keyRef
, but you release it. Remove that call.
Why didn't it crash before? Because something else was likely retaining it internally previously, possibly a cache, possibly something else. Cocoa makes no promises that an over-release will immediately (or ever) lead to a crash. You were into undefined behavior.
It's very distressing, though, that the static analyzer isn't detecting this. I would open a bug report about that (bugreport.apple.com). You have a very clear memory management violation and the analyzer should have caught it.