From adea90c119f88aafb60b6d3ec3e3894530c8b796 Mon Sep 17 00:00:00 2001 From: Markus Fisch Date: Tue, 28 May 2024 13:43:06 +0200 Subject: [PATCH 1/2] ios: release color space after use `CGColorSpaceCreateWithName` returns a `CGColorSpaceRef` which needs to be released with `CGColorSpaceRelease` to avoid leaking its memory. --- wrappers/ios/Sources/Wrapper/Reader/ZXIBarcodeReader.mm | 1 + 1 file changed, 1 insertion(+) diff --git a/wrappers/ios/Sources/Wrapper/Reader/ZXIBarcodeReader.mm b/wrappers/ios/Sources/Wrapper/Reader/ZXIBarcodeReader.mm index 46d1c980d6..37e5cb0e7e 100644 --- a/wrappers/ios/Sources/Wrapper/Reader/ZXIBarcodeReader.mm +++ b/wrappers/ios/Sources/Wrapper/Reader/ZXIBarcodeReader.mm @@ -109,6 +109,7 @@ - (instancetype)initWithOptions:(ZXIReaderOptions*)options{ cols, // Bytes per row colorSpace, // Colorspace kCGBitmapByteOrderDefault); // Bitmap info flags + CGColorSpaceRelease(colorSpace); CGContextDrawImage(contextRef, CGRectMake(0, 0, cols, rows), image); CGContextRelease(contextRef); From 78c535faa92b557a63cd0e2f045dc19f961c9617 Mon Sep 17 00:00:00 2001 From: Markus Fisch Date: Tue, 28 May 2024 13:49:55 +0200 Subject: [PATCH 2/2] ios: move creating color space before first use So its use is more clear, and to minimize the distance to the matching `CGColorSpaceRelease`. --- wrappers/ios/Sources/Wrapper/Reader/ZXIBarcodeReader.mm | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/wrappers/ios/Sources/Wrapper/Reader/ZXIBarcodeReader.mm b/wrappers/ios/Sources/Wrapper/Reader/ZXIBarcodeReader.mm index 37e5cb0e7e..9f1026b5d9 100644 --- a/wrappers/ios/Sources/Wrapper/Reader/ZXIBarcodeReader.mm +++ b/wrappers/ios/Sources/Wrapper/Reader/ZXIBarcodeReader.mm @@ -96,12 +96,11 @@ - (instancetype)initWithOptions:(ZXIReaderOptions*)options{ - (NSArray *)readCGImage:(nonnull CGImageRef)image error:(NSError *__autoreleasing _Nullable *)error { - CGColorSpaceRef colorSpace = CGColorSpaceCreateWithName(kCGColorSpaceGenericGray); CGFloat cols = CGImageGetWidth(image); CGFloat rows = CGImageGetHeight(image); NSMutableData *data = [NSMutableData dataWithLength: cols * rows]; - + CGColorSpaceRef colorSpace = CGColorSpaceCreateWithName(kCGColorSpaceGenericGray); CGContextRef contextRef = CGBitmapContextCreate(data.mutableBytes,// Pointer to backing data cols, // Width of bitmap rows, // Height of bitmap pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy