Merge pull request #29926 from simaotwx/patch-1

funcs: defer close file in filesha256
This commit is contained in:
James Bardin 2021-11-16 08:38:20 -05:00 committed by GitHub
commit db9109d2ce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 0 deletions

View File

@ -248,6 +248,7 @@ func makeFileHashFunction(baseDir string, hf func() hash.Hash, enc func([]byte)
if err != nil {
return cty.UnknownVal(cty.String), err
}
defer f.Close()
h := hf()
_, err = io.Copy(h, f)

View File

@ -377,6 +377,7 @@ func readFileBytes(baseDir, path string) ([]byte, error) {
}
return nil, err
}
defer f.Close()
src, err := ioutil.ReadAll(f)
if err != nil {