# fix : file close 没有关闭

This commit is contained in:
Farmerx 2018-08-20 16:53:51 +08:00 committed by GitHub
parent ec37b114c3
commit ce5b37a4ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 1 deletions

View File

@ -88,7 +88,11 @@ func (f *File) AddPicture(sheet, cell, picture, format string) error {
if !ok {
return errors.New("Unsupported image extension")
}
readFile, _ := os.Open(picture)
readFile, err := os.Open(picture)
if err!=nil{
return err
}
defer readFile.Close()
image, _, _ := image.DecodeConfig(readFile)
_, file := filepath.Split(picture)
formatSet, err := parseFormatPictureSet(format)