From af7833bb70fccc4f6870de53f5c934beee204f23 Mon Sep 17 00:00:00 2001 From: Adam Chalkley Date: Wed, 23 Aug 2023 06:28:03 -0500 Subject: [PATCH] govc: Fix memory aliasing in for loop (gosec G601) Fix gosec G601 "Implicit memory aliasing in for loop" error by reassigning the iteration variable inside the loop. refs GH-2243 refs GH-2269 --- govc/vm/snapshot/tree.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/govc/vm/snapshot/tree.go b/govc/vm/snapshot/tree.go index edc35a476..8fb8e3533 100644 --- a/govc/vm/snapshot/tree.go +++ b/govc/vm/snapshot/tree.go @@ -85,6 +85,8 @@ func (cmd *tree) Process(ctx context.Context) error { func (cmd *tree) write(level int, parent string, pref *types.ManagedObjectReference, st []types.VirtualMachineSnapshotTree) { for _, s := range st { + s := s // avoid implicit memory aliasing + sname := s.Name if cmd.fullPath && parent != "" {