Memory leaks when using SecTransformRef with kSecBase32Encoding
| Originator: | kishikawakatsumi | ||
| Number: | rdar://19757896 | Date Originated: | 08-Feb-2015 |
| Status: | Open | Resolved: | |
| Product: | OS X SDK | Product Version: | |
| Classification: | Serious Bug | Reproducible: | Always |
Instruments v6.1 (56160) and v6.2 (56717) detect a memory leak when creating SecTransformRef with kSecBase32Encoding and using it to encode a data into Base32.
If pass the parameter except kSecBase32Encoding, for example kSecBase64Encoding, does not happen memory leak. This happens only when specify a kSecBase32Encoding.
Steps to Reproduce:
1. Create a new project targeted for Mac application.
2. Type following code in AppDelegate.m.
#import "AppDelegate.h"
#import <Security/Security.h>
@interface AppDelegate ()
@property (weak) IBOutlet NSWindow *window;
@end
@implementation AppDelegate
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
NSData *data = [@"test" dataUsingEncoding:NSUTF8StringEncoding];
[self encodeData:data];
}
- (NSData *)encodeData:(NSData *)data {
SecTransformRef encoder = SecEncodeTransformCreate(kSecBase32Encoding, nil);
SecTransformSetAttribute(encoder, kSecTransformInputAttributeName, (__bridge CFDataRef)data, nil);
NSData *encodedData = (__bridge_transfer NSData *)SecTransformExecute(encoder, nil);
CFRelease(encoder);
return encodedData;
}
@end
3. Build and run the project using the Instruments.
4. Choose Leaks template.
Expected Results:
No memory leaks.
Actual Results:
Leaked object Malloc 32 bytes with __EncodeTransform_block_invode60 as responsible caller
Version:
OS X 10.10.2 (14C109)
Xcode 6.1.1 (6A2008a)
Xcode 6.2 (6C107a)
Xcode 6.2 (6C121)
Instruments Version 6.1 (56160)
Instruments Version 6.2 (56717)
Notes:
Configuration:
MacBookPro10,1, 16GB RAM
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!