Explorar el Código

Step of range should be a positive number

Step 0 will cause the parse function loop forever.
chenfeng2 hace 9 años
padre
commit
afe033740e
Se han modificado 1 ficheros con 3 adiciones y 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
 }