Repository: incubator-weex Updated Branches: refs/heads/master cf531a167 -> 9425cc92d
[WEEX-333][iOS] add protection for bezierPath contains nan point. Bug:333 [WEEX-333][iOS]fix check valid point logic Bug: 333 close #1144 Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/9425cc92 Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/9425cc92 Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/9425cc92 Branch: refs/heads/master Commit: 9425cc92d19201b59e240c5d86c6ec7575db6309 Parents: cf531a1 Author: acton393 <zhangxing610...@gmail.com> Authored: Thu May 3 17:58:21 2018 +0800 Committer: acton393 <zhangxing610...@gmail.com> Committed: Thu May 3 19:58:18 2018 +0800 ---------------------------------------------------------------------- ios/sdk/WeexSDK/Sources/Display/UIBezierPath+Weex.m | 16 +++++++++++++--- ios/sdk/WeexSDK/Sources/Utility/WXUtility.h | 9 +++++++++ ios/sdk/WeexSDK/Sources/Utility/WXUtility.m | 5 +++++ 3 files changed, 27 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/9425cc92/ios/sdk/WeexSDK/Sources/Display/UIBezierPath+Weex.m ---------------------------------------------------------------------- diff --git a/ios/sdk/WeexSDK/Sources/Display/UIBezierPath+Weex.m b/ios/sdk/WeexSDK/Sources/Display/UIBezierPath+Weex.m index b7aa821..7a74c3f 100644 --- a/ios/sdk/WeexSDK/Sources/Display/UIBezierPath+Weex.m +++ b/ios/sdk/WeexSDK/Sources/Display/UIBezierPath+Weex.m @@ -18,6 +18,7 @@ */ #import "UIBezierPath+Weex.h" +#import "WXUtility.h" @implementation UIBezierPath (Weex) @@ -32,13 +33,23 @@ static const float kCircleControlPoint = 0.447715; bottomRight:(CGFloat)bottomRightRadius { UIBezierPath *path = [UIBezierPath bezierPath]; - [path moveToPoint:CGPointMake(rect.origin.x + topLeftRadius, rect.origin.y)]; + if(isnan(topLeftRadius) || isnan(topRightRadius) || isnan(bottomLeftRadius) || isnan(bottomRightRadius)) { + return path; + } + if (![WXUtility isValidPoint:rect.origin] || isnan(rect.size.height) || isnan(rect.size.width)) { + return path; + } + CGPoint topLeftPoint = CGPointMake(rect.origin.x + topLeftRadius, rect.origin.y); + if (![WXUtility isValidPoint:topLeftPoint]) { + return path; + } + [path moveToPoint:topLeftPoint]; // +------------------+ // \\ top // // \\+----------+// CGPoint topRightPoint = CGPointMake(CGRectGetMaxX(rect) - topRightRadius, rect.origin.y); - if (isnan(topRightPoint.x) || isnan(topRightPoint.y)) { + if (![WXUtility isValidPoint:topRightPoint]) { return path; } [path addLineToPoint:topRightPoint]; @@ -101,5 +112,4 @@ static const float kCircleControlPoint = 0.447715; return path; } - @end http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/9425cc92/ios/sdk/WeexSDK/Sources/Utility/WXUtility.h ---------------------------------------------------------------------- diff --git a/ios/sdk/WeexSDK/Sources/Utility/WXUtility.h b/ios/sdk/WeexSDK/Sources/Utility/WXUtility.h index b1b852a..aee32c2 100644 --- a/ios/sdk/WeexSDK/Sources/Utility/WXUtility.h +++ b/ios/sdk/WeexSDK/Sources/Utility/WXUtility.h @@ -203,6 +203,15 @@ _Nonnull SEL WXSwizzledSelectorForSelector(_Nonnull SEL selector); */ + (BOOL)isBlankString:(NSString * _Nullable)string ; + +/** + check a point is valid or not. A zero point is also valid + + @param point a point value to check + @return true if point.x and point.y are all valid value for a number. + */ ++ (BOOL)isValidPoint:(CGPoint)point; + /** * @abstract Returns a standard error object * http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/9425cc92/ios/sdk/WeexSDK/Sources/Utility/WXUtility.m ---------------------------------------------------------------------- diff --git a/ios/sdk/WeexSDK/Sources/Utility/WXUtility.m b/ios/sdk/WeexSDK/Sources/Utility/WXUtility.m index dd3a35d..567ba9a 100644 --- a/ios/sdk/WeexSDK/Sources/Utility/WXUtility.m +++ b/ios/sdk/WeexSDK/Sources/Utility/WXUtility.m @@ -352,6 +352,11 @@ CGFloat WXFloorPixelValue(CGFloat value) return false; } ++ (BOOL)isValidPoint:(CGPoint)point +{ + return !(isnan(point.x)) && !(isnan(point.y)); +} + + (NSError *)errorWithCode:(NSInteger)code message:(NSString *)message { message = message ? : @"";