diff options
author | Ian Lance Taylor <iant@golang.org> | 2014-10-20 08:12:45 -0700 |
---|---|---|
committer | Ian Lance Taylor <iant@golang.org> | 2014-10-20 08:12:45 -0700 |
commit | 0f022fdd527db88419c1261b11e764a53ea41160 (patch) | |
tree | ea728552999e464d3a1a3ad0d12880e61e38048d /src/regexp/syntax/parse.go | |
parent | 3811c4d84aabc544f3431bf7fb59e9c57b183628 (diff) | |
download | go-0f022fdd527db88419c1261b11e764a53ea41160.tar.gz go-0f022fdd527db88419c1261b11e764a53ea41160.zip |
regexp/syntax: fix validity testing of zero repeats
This is already tested by TestRE2Exhaustive, but the build has
not broken because that test is not run when using -test.short.
LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/155580043
Diffstat (limited to 'src/regexp/syntax/parse.go')
-rw-r--r-- | src/regexp/syntax/parse.go | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/regexp/syntax/parse.go b/src/regexp/syntax/parse.go index 3dc8ccf503..d579a4069b 100644 --- a/src/regexp/syntax/parse.go +++ b/src/regexp/syntax/parse.go @@ -272,13 +272,18 @@ func (p *parser) repeat(op Op, min, max int, before, after, lastRepeat string) ( func repeatIsValid(re *Regexp, n int) bool { if re.Op == OpRepeat { m := re.Max + if m == 0 { + return true + } if m < 0 { m = re.Min } if m > n { return false } - n /= m + if m > 0 { + n /= m + } } for _, sub := range re.Sub { if !repeatIsValid(sub, n) { |