diff --git a/client/allocdir/alloc_dir.go b/client/allocdir/alloc_dir.go index 313070770..304f39067 100644 --- a/client/allocdir/alloc_dir.go +++ b/client/allocdir/alloc_dir.go @@ -514,11 +514,13 @@ func fileCopy(src, dst string, perm os.FileMode) error { if err != nil { return fmt.Errorf("Couldn't open src file %v: %v", src, err) } + defer srcFile.Close() dstFile, err := os.OpenFile(dst, os.O_WRONLY|os.O_CREATE, perm) if err != nil { return fmt.Errorf("Couldn't create destination file %v: %v", dst, err) } + defer dstFile.Close() if _, err := io.Copy(dstFile, srcFile); err != nil { return fmt.Errorf("Couldn't copy %v to %v: %v", src, dst, err)