mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00: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
2 changed files with 6 additions and 0 deletions
|
|
@ -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…
Add table
Add a link
Reference in a new issue