Skip to content

fix: restore closing SMTP message on method exit #14496

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 30, 2024
Merged

Conversation

dannykopping
Copy link
Contributor

Follow up of #14495

If we don't call message.Close() once the method exits, we could leak resources.
This restores the defer, but conditionalizes it such that it will only call Close() if it hasn't already been called. If we don't do this, the SMTP lib will send a subsequent line to the server after an error response, which is invalid. It's not a trainsmash, but it's better to be defensive.

.                                            <--- initial Close()
501 5.5.4 Rejected!
.                                            <--- deferred Close()
501 5.5.2 Bad command

Signed-off-by: Danny Kopping <danny@coder.com>
Signed-off-by: Danny Kopping <danny@coder.com>
@dannykopping dannykopping merged commit 0f414a0 into main Aug 30, 2024
27 checks passed
@dannykopping dannykopping deleted the dk/smtp-close-fix branch August 30, 2024 11:03
@github-actions github-actions bot locked and limited conversation to collaborators Aug 30, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants