Ver Fonte

Step of range should be a positive number

Step 0 will cause the parse function loop forever.
chenfeng2 há 9 anos atrás
pai
commit
afe033740e
1 ficheiros alterados com 3 adições e 0 exclusões
  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
 }