mirror of https://github.com/golang/go.git
runtime: handle non-nil-terminated environment strings on Plan 9
Russ Cox pointed out that environment strings are not required to be nil-terminated on Plan 9. LGTM=rsc R=rsc CC=golang-codereviews https://golang.org/cl/159130044
This commit is contained in:
parent
1946afb662
commit
9d06cfc810
|
|
@ -30,7 +30,7 @@ func gogetenv(key string) string {
|
|||
if fd < 0 {
|
||||
return ""
|
||||
}
|
||||
n := seek(fd, 0, 2) - 1
|
||||
n := seek(fd, 0, 2)
|
||||
if n <= 0 {
|
||||
close(fd)
|
||||
return ""
|
||||
|
|
@ -44,6 +44,10 @@ func gogetenv(key string) string {
|
|||
return ""
|
||||
}
|
||||
|
||||
if p[r-1] == 0 {
|
||||
r--
|
||||
}
|
||||
|
||||
var s string
|
||||
sp := (*_string)(unsafe.Pointer(&s))
|
||||
sp.str = &p[0]
|
||||
|
|
|
|||
Loading…
Reference in New Issue