From 7f6710a7b5120b8138411f80680921c1091d4c62 Mon Sep 17 00:00:00 2001 From: "pengfei.zhou" Date: Tue, 2 Aug 2022 11:02:03 +0800 Subject: [PATCH] iOS: protect setFrame incase crash --- doric-iOS/Pod/Classes/Shader/DoricLayouts.m | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/doric-iOS/Pod/Classes/Shader/DoricLayouts.m b/doric-iOS/Pod/Classes/Shader/DoricLayouts.m index aa127236..e499acf3 100644 --- a/doric-iOS/Pod/Classes/Shader/DoricLayouts.m +++ b/doric-iOS/Pod/Classes/Shader/DoricLayouts.m @@ -262,14 +262,21 @@ - (void)setFrame { } BOOL isFrameChange = ![self rect:originFrame equalTo:self.view.frame]; if (isFrameChange) { + if (isnan(originFrame.origin.x) || isinf(originFrame.origin.x) + || isnan(originFrame.origin.y) || isinf(originFrame.origin.y) + || isnan(originFrame.size.width) || isinf(originFrame.size.width) + || isnan(originFrame.size.height) || isinf(originFrame.size.height) + ) { + return; + } self.view.frame = originFrame; } if (!UIEdgeInsetsEqualToEdgeInsets(self.corners, UIEdgeInsetsZero)) { if (self.view.layer.mask) { if ([self.view.layer.mask isKindOfClass:[DoricShapeLayer class]]) { - DoricShapeLayer *shapeLayer = (DoricShapeLayer *)self.view.layer.mask; + DoricShapeLayer *shapeLayer = (DoricShapeLayer *) self.view.layer.mask; if (!UIEdgeInsetsEqualToEdgeInsets(self.corners, shapeLayer.corners) - || !CGRectEqualToRect(self.view.bounds, shapeLayer.viewBounds)) { + || !CGRectEqualToRect(self.view.bounds, shapeLayer.viewBounds)) { shapeLayer.corners = self.corners; shapeLayer.viewBounds = self.view.bounds; [self configMaskWithLayer:shapeLayer];