Fix CGMutablePathRef memory leaks when the path is invalid. (flutter/engine#14275)

This commit is contained in:
Wu Zhong
2019-12-12 07:52:29 +08:00
committed by Chinmay Garde
parent 7a8fde4337
commit fd89277550

View File

@@ -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<CGMutablePathRef> 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