mirror of
https://github.com/golang/go
synced 2024-11-22 02:44:39 -07: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:
parent
baf538406b
commit
7ffe938f08
@ -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
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user