Skip to content

Commit

Permalink
Defer only after checking err.
Browse files Browse the repository at this point in the history
Signed-off-by: Felix Fontein <felix@fontein.de>
  • Loading branch information
felixfontein authored and hiddeco committed Oct 3, 2023
1 parent 38ec3f7 commit f668c71
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion cmd/sops/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -321,10 +321,10 @@ func FixAWSKMSEncryptionContextBug(opts GenericDecryptOpts, tree *sops.Tree) (*s
}

file, err := os.Create(opts.InputPath)
defer file.Close()
if err != nil {
return nil, NewExitError(fmt.Sprintf("Could not open file for writing: %s", err), codes.CouldNotWriteOutputFile)
}
defer file.Close()
_, err = file.Write(encryptedFile)
if err != nil {
return nil, err
Expand Down

0 comments on commit f668c71

Please sign in to comment.