From 2a4daae578592de4ab223feda4efec7464d39b27 Mon Sep 17 00:00:00 2001 From: Moritz Marquardt Date: Mon, 16 Dec 2019 09:09:58 +0100 Subject: [PATCH] Provide workaround for segmentation fault (fixes #54) --- here/parse.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/here/parse.go b/here/parse.go index 9227b93..ef501f3 100644 --- a/here/parse.go +++ b/here/parse.go @@ -19,6 +19,10 @@ func (i Info) Parse(p string) (Path, error) { return i.build("", "", "") } + if pathrx == nil { + // Please do not move the initialization down to the declaration, see #54 + pathrx = regexp.MustCompile("([^:]+)(:(/.+))?") + } res := pathrx.FindAllStringSubmatch(p, -1) if len(res) == 0 { return Path{}, fmt.Errorf("could not parse %q", p) @@ -60,4 +64,4 @@ func (i Info) build(p, pkg, name string) (Path, error) { return pt, nil } -var pathrx = regexp.MustCompile("([^:]+)(:(/.+))?") +var pathrx *regexp.Regexp