From c178bd2d25a47e66a8307295e3e420b442f14037 Mon Sep 17 00:00:00 2001 From: Andrew Kitchen Date: Tue, 28 Nov 2017 14:51:30 -0800 Subject: [darwin] Fixes CGImageRef leak when creating a map snapshot (#10585) --- platform/darwin/src/MGLMapSnapshotter.mm | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/platform/darwin/src/MGLMapSnapshotter.mm b/platform/darwin/src/MGLMapSnapshotter.mm index dea93eba34..346666cf80 100644 --- a/platform/darwin/src/MGLMapSnapshotter.mm +++ b/platform/darwin/src/MGLMapSnapshotter.mm @@ -321,14 +321,18 @@ const CGFloat MGLSnapshotterMinimumPixelSize = 64; CIContext *ctx = [CIContext contextWithOptions:nil]; CGImageRef cgimg = [ctx createCGImage:blurredImage fromRect:[backgroundImage extent]]; + MGLImage *image; #if TARGET_OS_IPHONE - return [UIImage imageWithCGImage:cgimg]; + image = [UIImage imageWithCGImage:cgimg]; #else - return [[NSImage alloc] initWithCGImage:cgimg size:[backgroundImage extent].size]; + image = [[NSImage alloc] initWithCGImage:cgimg size:[backgroundImage extent].size]; #endif + + CGImageRelease(cgimg); + return image; } - (void)cancel -- cgit v1.2.1