Fix leaks of various CF types

This commit is contained in:
Jordan Rose 2020-09-29 16:45:45 -07:00 committed by Matthew Chen
parent d9d08b1553
commit 428002e439
3 changed files with 8 additions and 4 deletions

View File

@ -172,6 +172,7 @@ typedef void (^OWSAvatarDrawBlock)(CGContextRef context);
(id)[UIColor colorWithWhite:0.f alpha:0.15f].CGColor,
],
gradientLocations);
CFRelease(colorspace);
if (!gradient) {
return nil;
}

View File

@ -1,5 +1,5 @@
//
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
// Copyright (c) 2020 Open Whisper Systems. All rights reserved.
//
#import "OWSHTTPSecurityPolicy.h"
@ -46,11 +46,13 @@ NS_ASSUME_NONNULL_BEGIN
}
+ (NSData *)certificateDataForService:(NSString *)service {
SecCertificateRef certRef = [self certificateForService:service];
return (__bridge_transfer NSData *)SecCertificateCopyData(certRef);
SecCertificateRef certRef = [self newCertificateForService:service];
NSData *result = (__bridge_transfer NSData *)SecCertificateCopyData(certRef);
CFRelease(certRef);
return result;
}
+ (SecCertificateRef)certificateForService:(NSString *)service
+ (SecCertificateRef)newCertificateForService:(NSString *)service CF_RETURNS_RETAINED
{
NSData *certificateData = [self dataFromCertificateFileForService:service];
return SecCertificateCreateWithData(NULL, (__bridge CFDataRef)(certificateData));

View File

@ -528,6 +528,7 @@ typedef struct {
}
UIImage *uiImage = [UIImage imageWithCGImage:cgImage];
CFRelease(cgImage);
return uiImage;
}