Skip to content

Commit

Permalink
govc: Fix memory aliasing in for loop (gosec G601)
Browse files Browse the repository at this point in the history
Fix gosec G601 "Implicit memory aliasing in for loop" error
by reassigning the iteration variable inside the loop.

refs GH-2243
refs GH-2269
  • Loading branch information
atc0005 committed Aug 23, 2023
1 parent c63291a commit af7833b
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions govc/vm/snapshot/tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 != "" {
Expand Down

0 comments on commit af7833b

Please sign in to comment.