Skip to content

Commit

Permalink
Fix shadowed variable bug
Browse files Browse the repository at this point in the history
This code caused the singleton `trustedRoot` to be returned as nil on subsequent calls. The singleton was shadowed when the variable was redeclared in the `if` block.

Signed-off-by: Cody Soyland <[email protected]>
  • Loading branch information
codysoyland committed Sep 17, 2024
1 parent 4d0a2d6 commit 3720290
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/tuf/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ func GetTrustedRoot(ctx context.Context) (*root.TrustedRoot, error) {
singletonRootError = fmt.Errorf("error getting targets: %w", err)
return nil, singletonRootError
}
trustedRoot, err := root.NewTrustedRootFromJSON(targetBytes)
trustedRoot, err = root.NewTrustedRootFromJSON(targetBytes)
if err != nil {
singletonRootError = fmt.Errorf("error creating trusted root: %w", err)
return nil, singletonRootError
Expand Down

0 comments on commit 3720290

Please sign in to comment.