]> Cypherpunks repositories - gostls13.git/commit
[release-branch.go1.13] cmd/go: do not append to the global cfg.OrigEnv slice
authorBryan C. Mills <bcmills@google.com>
Thu, 26 Mar 2020 02:24:44 +0000 (22:24 -0400)
committerAndrew Bonventre <andybons@golang.org>
Thu, 26 Mar 2020 21:10:41 +0000 (21:10 +0000)
commitb2797dc8739d19ed788357df852daa332f632853
tree783d48ff010097df1e72e84f48ca291bb90bc288
parentd6224d3807534d1d6638e5bbd1d5a1ce23e99ec9
[release-branch.go1.13] cmd/go: do not append to the global cfg.OrigEnv slice

Appending to a global slice is only safe if its length is already
equal to its capacity. That property is not guaranteed for slices in
general, and empirically does not hold for this one.

This is a minimal fix to make it easier to backport.
A more robust cleanup of the base.EnvForDir function will be sent in a
subsequent CL.

Fixes #38082
Updates #38077

Change-Id: I731d5bbd0e516642c2cf43e713eeea15402604e5
Reviewed-on: https://go-review.googlesource.com/c/go/+/225577
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
(cherry picked from commit bfb1342a40216cba0ff5ae3a1b102823b7603068)
Reviewed-on: https://go-review.googlesource.com/c/go/+/225660
src/cmd/go/internal/generate/generate.go
src/cmd/go/internal/test/test.go