From commits-return-12164-archive-asf-public=cust-asf.ponee.io@weex.incubator.apache.org Thu May 3 13:59:17 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id A6DE1180625 for ; Thu, 3 May 2018 13:59:16 +0200 (CEST) Received: (qmail 41817 invoked by uid 500); 3 May 2018 11:59:15 -0000 Mailing-List: contact commits-help@weex.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@weex.incubator.apache.org Delivered-To: mailing list commits@weex.incubator.apache.org Received: (qmail 41808 invoked by uid 99); 3 May 2018 11:59:15 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 03 May 2018 11:59:15 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id 437211A020E for ; Thu, 3 May 2018 11:59:15 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -4.211 X-Spam-Level: X-Spam-Status: No, score=-4.211 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, RCVD_IN_DNSWL_HI=-5, SPF_PASS=-0.001, T_RP_MATCHES_RCVD=-0.01] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id 39LouZ9GanPM for ; Thu, 3 May 2018 11:59:13 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with SMTP id CE6D45F254 for ; Thu, 3 May 2018 11:59:12 +0000 (UTC) Received: (qmail 41770 invoked by uid 99); 3 May 2018 11:59:12 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 03 May 2018 11:59:12 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id E47A4F3216; Thu, 3 May 2018 11:59:11 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: acton393@apache.org To: commits@weex.incubator.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: incubator-weex git commit: [WEEX-333][iOS] add protection for bezierPath contains nan point. Date: Thu, 3 May 2018 11:59:11 +0000 (UTC) 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 Authored: Thu May 3 17:58:21 2018 +0800 Committer: acton393 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 ? : @"";