Skip to content
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

Memory leak: file is not closed if TransferOpen() fails #69

Closed
marshallbrekka opened this issue Feb 15, 2018 · 2 comments
Closed

Memory leak: file is not closed if TransferOpen() fails #69

marshallbrekka opened this issue Feb 15, 2018 · 2 comments
Assignees
Labels

Comments

@marshallbrekka
Copy link
Collaborator

marshallbrekka commented Feb 15, 2018

https://github.com/fclairamb/ftpserver/blob/d06e1a0d4a20bf8a311961952b15c550a1acbfd9/server/handle_files.go#L22-L35

The file opened on line 22 is never closed if the TransferOpen() call fails.
You could of course call file.Close() within that else block, my only concern is that still results in an empty file being created.

Another option is to call TransferOpen() first, and then attempt to open the file.

I can submit a PR once a solution is agreed upon.

@fclairamb fclairamb added the Bug label Feb 15, 2018
@fclairamb fclairamb self-assigned this Feb 15, 2018
@fclairamb
Copy link
Owner

I just checked, in that scenario, proftpd creates an empty file.

So I think it's quite acceptable to behave the same way.

@fclairamb
Copy link
Owner

PR #71 fixes this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants