1
0
mirror of https://github.com/astaxie/beego.git synced 2024-06-14 23:53:32 +00:00

leak opened file

should defer file.Close()
This commit is contained in:
cloudzhou 2019-09-27 19:27:44 +08:00 committed by GitHub
parent 11774c87a5
commit 5a5482c77f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -175,6 +175,7 @@ func (e *Email) AttachFile(args ...string) (a *Attachment, err error) {
if err != nil {
return
}
defer f.Close()
ct := mime.TypeByExtension(filepath.Ext(filename))
basename := path.Base(filename)
return e.Attach(f, basename, ct, id)