Skip to content

Commit 9e4c6ad

Browse files
zhongwuzwchinmaygarde
authored andcommitted
Fix CGMutablePathRef memory leaks when the path is invalid. (#14275)
1 parent 9dc23b8 commit 9e4c6ad

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.mm

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
#include "flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.h"
66

7+
#include "flutter/fml/platform/darwin/cf_utils.h"
78
#include "flutter/shell/platform/darwin/ios/ios_surface.h"
89

910
static int kMaxPointsInVerb = 4;
@@ -132,15 +133,14 @@ - (void)clipRRect:(const SkRRect&)clipSkRRect {
132133
}
133134

134135
- (void)clipPath:(const SkPath&)path {
135-
CGMutablePathRef pathRef = CGPathCreateMutable();
136136
if (!path.isValid()) {
137137
return;
138138
}
139+
fml::CFRef<CGMutablePathRef> pathRef(CGPathCreateMutable());
139140
if (path.isEmpty()) {
140141
CAShapeLayer* clip = [[CAShapeLayer alloc] init];
141142
clip.path = pathRef;
142143
self.layer.mask = clip;
143-
CGPathRelease(pathRef);
144144
return;
145145
}
146146

@@ -198,7 +198,6 @@ - (void)clipPath:(const SkPath&)path {
198198
CAShapeLayer* clip = [[CAShapeLayer alloc] init];
199199
clip.path = pathRef;
200200
self.layer.mask = clip;
201-
CGPathRelease(pathRef);
202201
}
203202

204203
- (void)setClip:(flutter::MutatorType)type

0 commit comments

Comments
 (0)