Skip to content

caddytest: close temp config file handle in validateTestPrerequisites#7839

Open
vvdvortsova wants to merge 1 commit into
caddyserver:masterfrom
vvdvortsova:fix-7833-4-add-close
Open

caddytest: close temp config file handle in validateTestPrerequisites#7839
vvdvortsova wants to merge 1 commit into
caddyserver:masterfrom
vvdvortsova:fix-7833-4-add-close

Conversation

@vvdvortsova

Copy link
Copy Markdown

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.

validateTestPrerequisites in caddytest/caddytest.go created a temp file via os.CreateTemp and only removed it from disk in t.Cleanup (os.Remove(f.Name())), never closing the file descriptor including on the early return err if writing the config failed. Added defer f.Close() right after the file is created.

Testing
go build ./caddytest/...
go vet ./caddytest/...

@CLAassistant

CLAassistant commented Jun 23, 2026

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants