Prevent panic for zero-length input
This commit is contained in:
parent
13808e841e
commit
d9fa9bddda
4
pcre.go
4
pcre.go
@ -574,6 +574,10 @@ func replaceBytes(src, repl []byte, sOff, eOff lib.Tsize_t, diff int64) (int64,
|
|||||||
// match calls the underlying pcre match functions. It re-runs the functions
|
// match calls the underlying pcre match functions. It re-runs the functions
|
||||||
// until no matches are found if multi is set to true.
|
// until no matches are found if multi is set to true.
|
||||||
func (r *Regexp) match(b []byte, options uint32, multi bool) ([][]lib.Tsize_t, error) {
|
func (r *Regexp) match(b []byte, options uint32, multi bool) ([][]lib.Tsize_t, error) {
|
||||||
|
if len(b) == 0 {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
r.mtx.Lock()
|
r.mtx.Lock()
|
||||||
defer r.mtx.Unlock()
|
defer r.mtx.Unlock()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user