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
}