forked from p30928647/excelize
Fix potential memory leak
Fix potential memory leak where zw is not Close() when an error occurs.
This commit is contained in:
parent
448f5524a8
commit
5107928892
2
file.go
2
file.go
|
@ -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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue