Skip to content

Commit 00e2a1c

Browse files
anik120tmshort
authored andcommitted
(fix) declCfg non-closed file descriptor (#1625)
Upstream-repository: operator-registry Upstream-commit: f97b4afe23d806c66779d2cebb85a29363cdbf01
1 parent 9437512 commit 00e2a1c

File tree

2 files changed

+22
-12
lines changed
  • staging/operator-registry/alpha/declcfg
  • vendor/github.com/operator-framework/operator-registry/alpha/declcfg

2 files changed

+22
-12
lines changed

staging/operator-registry/alpha/declcfg/load.go

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -183,15 +183,20 @@ func parseMetaPaths(ctx context.Context, root fs.FS, pathChan <-chan string, wal
183183
if !ok {
184184
return nil
185185
}
186-
file, err := root.Open(path)
186+
err := func() error { // using closure to ensure file is closed immediately after use
187+
file, err := root.Open(path)
188+
if err != nil {
189+
return err
190+
}
191+
defer file.Close()
192+
193+
return WalkMetasReader(file, func(meta *Meta, err error) error {
194+
return walkFn(path, meta, err)
195+
})
196+
}()
187197
if err != nil {
188198
return err
189199
}
190-
if err := WalkMetasReader(file, func(meta *Meta, err error) error {
191-
return walkFn(path, meta, err)
192-
}); err != nil {
193-
return err
194-
}
195200
}
196201
}
197202
}

vendor/github.com/operator-framework/operator-registry/alpha/declcfg/load.go

Lines changed: 11 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)