Commit 7ffe938f authored by Rob Pike's avatar Rob Pike

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

R=gri
CC=golang-dev
https://golang.org/cl/787041
parent baf53840
......@@ -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
}
......
......@@ -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
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment