From fd89277550cb4a861c1eef28c58b32935b3b66b1 Mon Sep 17 00:00:00 2001 From: Wu Zhong Date: Thu, 12 Dec 2019 07:52:29 +0800 Subject: [PATCH] Fix CGMutablePathRef memory leaks when the path is invalid. (flutter/engine#14275) --- .../ios/framework/Source/FlutterPlatformViews_Internal.mm | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.mm b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.mm index dc91dde315..c29c749164 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.mm +++ b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.mm @@ -4,6 +4,7 @@ #include "flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.h" +#include "flutter/fml/platform/darwin/cf_utils.h" #include "flutter/shell/platform/darwin/ios/ios_surface.h" static int kMaxPointsInVerb = 4; @@ -132,15 +133,14 @@ void ResetAnchor(CALayer* layer) { } - (void)clipPath:(const SkPath&)path { - CGMutablePathRef pathRef = CGPathCreateMutable(); if (!path.isValid()) { return; } + fml::CFRef pathRef(CGPathCreateMutable()); if (path.isEmpty()) { CAShapeLayer* clip = [[CAShapeLayer alloc] init]; clip.path = pathRef; self.layer.mask = clip; - CGPathRelease(pathRef); return; } @@ -198,7 +198,6 @@ void ResetAnchor(CALayer* layer) { CAShapeLayer* clip = [[CAShapeLayer alloc] init]; clip.path = pathRef; self.layer.mask = clip; - CGPathRelease(pathRef); } - (void)setClip:(flutter::MutatorType)type