aboutsummaryrefslogtreecommitdiffstats
path: root/util/lamport
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2023-01-11 14:22:28 +0100
committerMichael Muré <batolettre@gmail.com>2023-01-11 14:22:58 +0100
commitace0f055074a6ecee0f9893d545f0ff6f7fc3c45 (patch)
tree1c6732eb1a87ee9f65da62a6cf156bd441a2f02a /util/lamport
parent2664332bfd17094dd8a485ea085099d6eac33068 (diff)
downloadgit-bug-ace0f055074a6ecee0f9893d545f0ff6f7fc3c45.tar.gz
properly close files in edge cases in various places
Diffstat (limited to 'util/lamport')
-rw-r--r--util/lamport/persisted_clock.go11
1 files changed, 8 insertions, 3 deletions
diff --git a/util/lamport/persisted_clock.go b/util/lamport/persisted_clock.go
index b9246f73..a069b379 100644
--- a/util/lamport/persisted_clock.go
+++ b/util/lamport/persisted_clock.go
@@ -3,7 +3,7 @@ package lamport
import (
"errors"
"fmt"
- "io/ioutil"
+ "io"
"os"
"github.com/go-git/go-billy/v5"
@@ -77,9 +77,14 @@ func (pc *PersistedClock) read() error {
if err != nil {
return err
}
- defer f.Close()
- content, err := ioutil.ReadAll(f)
+ content, err := io.ReadAll(f)
+ if err != nil {
+ _ = f.Close()
+ return err
+ }
+
+ err = f.Close()
if err != nil {
return err
}