caddytest: close temp config file handle in validateTestPrerequisites#7839
caddytest: close temp config file handle in validateTestPrerequisites#7839vvdvortsova wants to merge 1 commit into
Conversation
|
This should close the temp file before starting Caddy from it. With the current defer, the handle stays open until ValidateTestPrerequisites returns so Caddy may still read the config while the writer handle is open. Closing immediately after the fmt.Fprintf succeeds would be cleaner. We also need a signed CLA and an AI assistance disclosure, please. |
6872e99 to
9c3bedf
Compare
I added signed CLA and added |
I'm not a native English speaker, so I used AI to help translate this PR description. The code and analysis are my own.
What
Fix resource leak in
validateTestPrerequisites.Fix for issue #7833.
validateTestPrerequisitesincaddytest/caddytest.gocreated a temp file viaos.CreateTempand only removed it from disk int.Cleanup(os.Remove(f.Name())), never closing the file descriptor including on the earlyreturn errif writing the config failed. Addeddefer f.Close()right after the file is created.Testing
go build ./caddytest/...go vet ./caddytest/...