Commit 20d9cc4b authored by David du Colombier's avatar David du Colombier Committed by Russ Cox

runtime: fix gogetenv on Plan 9

LGTM=rsc
R=rsc, ality
CC=golang-codereviews
https://golang.org/cl/137030043
parent 649c8353
......@@ -30,21 +30,11 @@ func gogetenv(key string) string {
if fd < 0 {
return ""
}
n := seek(fd, 0, 2)
var p unsafe.Pointer
// Be sure not to allocate for $GOTRACEBACK.
if key == "GOTRACEBACK" {
if n >= 128 {
return ""
}
p = unsafe.Pointer(&tracebackbuf[0])
} else {
p = gomallocgc(uintptr(n+1), nil, 0)
}
n := seek(fd, 0, 2) - 1
p := make([]byte, n)
r := pread(fd, p, int32(n), 0)
r := pread(fd, unsafe.Pointer(&p[0]), int32(n), 0)
close(fd)
if r < 0 {
return ""
......@@ -52,7 +42,7 @@ func gogetenv(key string) string {
var s string
sp := (*_string)(unsafe.Pointer(&s))
sp.str = (*byte)(p)
sp.str = &p[0]
sp.len = int(r)
return s
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment