Skip to content

Commit

Permalink
Fix CGMutablePathRef memory leaks when the path is invalid. (flutter#…
Browse files Browse the repository at this point in the history
  • Loading branch information
zhongwuzw authored and chinmaygarde committed Dec 11, 2019
1 parent 9dc23b8 commit 9e4c6ad
Showing 1 changed file with 2 additions and 3 deletions.
Expand Up @@ -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;
Expand Down Expand Up @@ -132,15 +133,14 @@ - (void)clipRRect:(const SkRRect&)clipSkRRect {
}

- (void)clipPath:(const SkPath&)path {
CGMutablePathRef pathRef = CGPathCreateMutable();
if (!path.isValid()) {
return;
}
fml::CFRef<CGMutablePathRef> pathRef(CGPathCreateMutable());
if (path.isEmpty()) {
CAShapeLayer* clip = [[CAShapeLayer alloc] init];
clip.path = pathRef;
self.layer.mask = clip;
CGPathRelease(pathRef);
return;
}

Expand Down Expand Up @@ -198,7 +198,6 @@ - (void)clipPath:(const SkPath&)path {
CAShapeLayer* clip = [[CAShapeLayer alloc] init];
clip.path = pathRef;
self.layer.mask = clip;
CGPathRelease(pathRef);
}

- (void)setClip:(flutter::MutatorType)type
Expand Down

0 comments on commit 9e4c6ad

Please sign in to comment.