Skip to content

Commit c89d60b

Browse files
zhongwuzwDmitry Lyzlov
authored andcommitted
Fix CGMutablePathRef memory leaks when the path is invalid. (flutter#14275)
1 parent 91c813b commit c89d60b

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;
@@ -131,15 +132,14 @@ - (void)clipRRect:(const SkRRect&)clipSkRRect {
131132
}
132133

133134
- (void)clipPath:(const SkPath&)path {
134-
CGMutablePathRef pathRef = CGPathCreateMutable();
135135
if (!path.isValid()) {
136136
return;
137137
}
138+
fml::CFRef<CGMutablePathRef> pathRef(CGPathCreateMutable());
138139
if (path.isEmpty()) {
139140
CAShapeLayer* clip = [[[CAShapeLayer alloc] init] autorelease];
140141
clip.path = pathRef;
141142
self.layer.mask = clip;
142-
CGPathRelease(pathRef);
143143
return;
144144
}
145145

@@ -197,7 +197,6 @@ - (void)clipPath:(const SkPath&)path {
197197
CAShapeLayer* clip = [[[CAShapeLayer alloc] init] autorelease];
198198
clip.path = pathRef;
199199
self.layer.mask = clip;
200-
CGPathRelease(pathRef);
201200
}
202201

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

0 commit comments

Comments
 (0)