aboutsummaryrefslogtreecommitdiff
path: root/src/syscall/exec_unix.go
diff options
context:
space:
mode:
authorRoland Shoemaker <roland@golang.org>2023-06-02 08:49:47 -0700
committerRoland Shoemaker <roland@golang.org>2023-06-05 15:22:32 +0000
commit96b79bd3208078835d6a1b9b8c7050554eccc734 (patch)
tree30c156fca5a9883c9e7ae60d488e6edadb53539b /src/syscall/exec_unix.go
parent05293d6b499afe9f37c11582c4a9a41fd92ba258 (diff)
downloadgo-96b79bd3208078835d6a1b9b8c7050554eccc734.tar.xz
syscall: don't panic when argv is nil on freebsd
The workaround in CL 69970044 introduced a panic when StartProcess is called with empty argv. Check the length before trying to access it. Change-Id: Ic948d86c7067a21c484ba24e100d1f1f80179730 Reviewed-on: https://go-review.googlesource.com/c/go/+/500415 Run-TryBot: Roland Shoemaker <roland@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com>
Diffstat (limited to 'src/syscall/exec_unix.go')
-rw-r--r--src/syscall/exec_unix.go2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/syscall/exec_unix.go b/src/syscall/exec_unix.go
index 4b9c04db83..14edd023d3 100644
--- a/src/syscall/exec_unix.go
+++ b/src/syscall/exec_unix.go
@@ -165,7 +165,7 @@ func forkExec(argv0 string, argv []string, attr *ProcAttr) (pid int, err error)
return 0, err
}
- if (runtime.GOOS == "freebsd" || runtime.GOOS == "dragonfly") && len(argv[0]) > len(argv0) {
+ if (runtime.GOOS == "freebsd" || runtime.GOOS == "dragonfly") && len(argv) > 0 && len(argv[0]) > len(argv0) {
argvp[0] = argv0p
}