Merge pull request #469 from zaddok/patch-1

Fix potential memory leak
This commit is contained in:
xuri 2019-08-10 00:07:09 +08:00 committed by GitHub
commit 23c8d1ec8a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 0 deletions

View File

@ -109,10 +109,12 @@ func (f *File) WriteToBuffer() (*bytes.Buffer, error) {
for path, content := range f.XLSX { for path, content := range f.XLSX {
fi, err := zw.Create(path) fi, err := zw.Create(path)
if err != nil { if err != nil {
zw.Close()
return buf, err return buf, err
} }
_, err = fi.Write(content) _, err = fi.Write(content)
if err != nil { if err != nil {
zw.Close()
return buf, err return buf, err
} }
} }