Skip to content

Commit faadda0

Browse files
empijeibradfitz
authored andcommitted
os: add check for empty executable path on darwin
os used to panic (access out of bounds) if executablePath was left empty Fixes #22529 Change-Id: Iead5e60a3b000dbde421a8e8612c3690340879ce Reviewed-on: https://go-review.googlesource.com/127546 Run-TryBot: Ian Lance Taylor <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Brad Fitzpatrick <[email protected]>
1 parent b3b2f5d commit faadda0

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/os/executable_darwin.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,17 @@
44

55
package os
66

7+
import "errors"
8+
79
var executablePath string // set by ../runtime/os_darwin.go
810

911
var initCwd, initCwdErr = Getwd()
1012

1113
func executable() (string, error) {
1214
ep := executablePath
15+
if len(ep) == 0 {
16+
return ep, errors.New("cannot find executable path")
17+
}
1318
if ep[0] != '/' {
1419
if initCwdErr != nil {
1520
return ep, initCwdErr

0 commit comments

Comments
 (0)