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 | 53e3043abdfafde7ef47d40aa8031aa4206d439e (patch) | |
tree | ea4eb91e52142529a84547c0b97cd60cf2eaad5d /src/regexp | |
parent | 423e70cdc8adb844fa5032ed2af1dc0480a93fbd (diff) | |
download | go-53e3043abdfafde7ef47d40aa8031aa4206d439e.tar.gz |
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://codereview.appspot.com/155580043
Diffstat (limited to 'src/regexp')
-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 3dc8ccf50..d579a4069 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) { |