This is an automated email from the ASF dual-hosted git repository. moshen pushed a commit to branch fix-nan-timer in repository https://gitbox.apache.org/repos/asf/incubator-weex.git
commit 2045413e34f9ba210dd3951575c0e2a8ded896f4 Author: qianyuan.wqy <[email protected]> AuthorDate: Thu Oct 24 15:57:04 2019 +0800 [iOS] Fix crash that creating timer with NAN interval. --- ios/sdk/WeexSDK/Sources/Module/WXTimerModule.m | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ios/sdk/WeexSDK/Sources/Module/WXTimerModule.m b/ios/sdk/WeexSDK/Sources/Module/WXTimerModule.m index d036409..2d8b7fa 100644 --- a/ios/sdk/WeexSDK/Sources/Module/WXTimerModule.m +++ b/ios/sdk/WeexSDK/Sources/Module/WXTimerModule.m @@ -161,6 +161,12 @@ WX_EXPORT_METHOD(@selector(clearInterval:)) - (void)createTimerWithCallback:(NSString *)callbackID time:(NSTimeInterval)milliseconds target:(id)target selector:(SEL)selector shouldRepeat:(BOOL)shouldRepeat { + WXAssert(!isnan(milliseconds), @"Timer interval is NAN."); + if (isnan(milliseconds)) { + WXLogError(@"Create timer with NAN interval."); + return; + } + NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval:milliseconds/1000.0f target:target selector:selector userInfo:nil repeats:shouldRepeat]; [[NSRunLoop mainRunLoop] addTimer:timer forMode:NSRunLoopCommonModes];
