From a0321cd172b4b2bccb5076a0f5664f3631b6c41f Mon Sep 17 00:00:00 2001 From: takumakanari Date: Thu, 24 Nov 2016 18:55:05 +0900 Subject: [PATCH] fix infinite lopp on cron expression '*/60 * * * *' --- cronexpr_parse.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/cronexpr_parse.go b/cronexpr_parse.go index aeb8296..d339f0c 100644 --- a/cronexpr_parse.go +++ b/cronexpr_parse.go @@ -18,6 +18,7 @@ import ( "fmt" "regexp" "sort" + "strconv" "strings" ) @@ -445,7 +446,13 @@ func genericFieldParse(s string, desc fieldDescriptor) ([]*cronDirective, error) directive.kind = span directive.first = desc.min directive.last = desc.max - directive.step = atoi(snormal[pairs[2]:pairs[3]]) + + if step, err := strconv.Atoi(snormal[pairs[2]:pairs[3]]); err != nil { + return nil, err + } else { + directive.step = step + } + directives = append(directives, &directive) continue }