build: fix file handle leak in GitHub release tool

This is a small patch to remove a defer statement found in a for loop.
It instead closes the file after it is done copying the bytes from the
tar file reader.
This commit is contained in:
Garrett Squire 2020-07-04 02:51:37 -07:00 committed by GitHub
parent d4b2709fb0
commit 4f7f5404ce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -374,16 +374,13 @@ func untar(srcFile, fileName, extractDir string) {
if err != nil {
log.Fatalf("Couldn't open output file: %v", err)
}
defer func() {
err := out.Close()
if err != nil {
log.Fatalf("Couldn't close output: %v", err)
}
}()
n, err := io.Copy(out, tarReader)
if err != nil {
log.Fatalf("Couldn't write output file: %v", err)
}
if err = out.Close(); err != nil {
log.Fatalf("Couldn't close output: %v", err)
}
log.Printf("Wrote %s (%d bytes) as %q", fileName, n, outPath)
}
}