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

the file handle doesn't be closed #1999

Open
ymcvalu opened this issue Jul 24, 2019 · 3 comments
Open

the file handle doesn't be closed #1999

ymcvalu opened this issue Jul 24, 2019 · 3 comments

Comments

@ymcvalu
Copy link

ymcvalu commented Jul 24, 2019

gin/context.go

Line 525 in 502c898

_, fh, err := c.Request.FormFile(name)

the request.FormFile will call the FileHeader.Open:

func (fh *FileHeader) Open() (File, error) {
	if b := fh.content; b != nil {
		r := io.NewSectionReader(bytes.NewReader(b), 0, int64(len(b)))
		return sectionReadCloser{r}, nil
	}
	return os.Open(fh.tmpfile) // it is posibble to open a disk file
}
@yilcool
Copy link

yilcool commented Oct 3, 2019

yes

@yilcool
Copy link

yilcool commented Oct 3, 2019

帅哥,不关闭会内存泄露

@ymcvalu
Copy link
Author

ymcvalu commented Oct 6, 2019

帅哥,不关闭会内存泄露

Context.FormFile这个方法里面,没有关闭,直接忽略了

@ymcvalu ymcvalu changed the title is it needed to close the file handle? don't close the file handle Oct 15, 2019
@ymcvalu ymcvalu changed the title don't close the file handle the file handle doesn't be closed Oct 15, 2019
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

No branches or pull requests

2 participants