Skip to content

Commit 3e395ec

Browse files
authored
Merge pull request #2522 from alexandear/fix-add-missing-file-close
Add missing file.Close() method calls
2 parents 18e18af + e6adae6 commit 3e395ec

File tree

4 files changed

+4
-0
lines changed

4 files changed

+4
-0
lines changed

pkg/editutil/editutil.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ func OpenEditor(content []byte, hdr string) ([]byte, error) {
6464
tmpYAMLPath := tmpYAMLFile.Name()
6565
defer os.RemoveAll(tmpYAMLPath)
6666
if _, err := tmpYAMLFile.Write(append([]byte(hdr), content...)); err != nil {
67+
tmpYAMLFile.Close()
6768
return nil, err
6869
}
6970
if err := tmpYAMLFile.Close(); err != nil {

pkg/qemu/entitlementutil/entitlementutil.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ func Sign(qExe string) error {
5151
</dict>
5252
</plist>`
5353
if _, err = ent.WriteString(entXML); err != nil {
54+
ent.Close()
5455
return fmt.Errorf("failed to write to a temporary file %q for signing QEMU binary: %w", entName, err)
5556
}
5657
ent.Close()

pkg/wsl2/vm_windows.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ func provisionVM(ctx context.Context, instanceDir, instanceName, distroName stri
8181
return err
8282
}
8383
if _, err = limaBootFile.Write(limaBootB); err != nil {
84+
limaBootFile.Close()
8485
return err
8586
}
8687
limaBootFileWinPath := limaBootFile.Name()

pkg/yqutil/yqutil.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ func EvaluateExpression(expression string, content []byte) ([]byte, error) {
2222
defer os.RemoveAll(tmpYAMLPath)
2323
_, err = tmpYAMLFile.Write(content)
2424
if err != nil {
25+
tmpYAMLFile.Close()
2526
return nil, err
2627
}
2728
if err = tmpYAMLFile.Close(); err != nil {

0 commit comments

Comments
 (0)