]> Cypherpunks repositories - gostls13.git/commit
[release-branch.go1.14] 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:36 +0000 (21:10 +0000)
commit612ef03a232edcb43e2dff6943b2a8167647ba78
treea869be12ebff896a7c11ed6bda5d427527a04174
parentb43b463d8fd3b15e9feb5156ff13b51ffa6f4599
[release-branch.go1.14] 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 #38083
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/+/225659
src/cmd/go/internal/generate/generate.go
src/cmd/go/internal/test/test.go