Explorar o código

Step of range should be a positive number

Step 0 will cause the parse function loop forever.
chenfeng2 %!s(int64=9) %!d(string=hai) anos
pai
achega
afe033740e
Modificáronse 1 ficheiros con 3 adicións e 0 borrados
  1. 3 0
      parser.go

+ 3 - 0
parser.go

@@ -114,6 +114,9 @@ func getRange(expr string, r bounds) uint64 {
 	if start > end {
 		log.Panicf("Beginning of range (%d) beyond end of range (%d): %s", start, end, expr)
 	}
+	if step == 0 {
+		log.Panicf("Step of range should be a positive number: %s", expr)
+	}
 
 	return getBits(start, end, step) | extra_star
 }