1
0
mirror of https://github.com/golang/go synced 2024-09-25 03:10:12 -06:00

regexp: don't return non-nil *Regexp if there is an error.

R=gri
CC=golang-dev
https://golang.org/cl/787041
This commit is contained in:
Rob Pike 2010-03-26 16:18:20 -07:00
parent baf538406b
commit 7ffe938f08
2 changed files with 6 additions and 0 deletions

View File

@ -664,6 +664,9 @@ func Compile(str string) (regexp *Regexp, error os.Error) {
regexp.expr = str
regexp.inst = new(vector.Vector)
error = regexp.doParse()
if error != nil {
regexp = nil
}
return
}

View File

@ -615,6 +615,9 @@ func CompileRegexp(str string) (regexp *Regexp, error string) {
regexp.expr = str
regexp.inst = make([]instr, 0, 20)
error = regexp.doParse()
if error != nil {
regexp = nil
}
return
}