Skip to content

Commit 89bed74

Browse files
songzhibin97ucwong
authored andcommitted
accounts, cmd/geth, core: close opened files (#29598)
* fix: open file used up but not closed * feat: more same case * feat: accept conversation
1 parent f1189a5 commit 89bed74

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

accounts/keystore/keystore.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -321,11 +321,10 @@ func (ks *KeyStore) Unlock(a accounts.Account, passphrase string) error {
321321
// Lock removes the private key with the given address from memory.
322322
func (ks *KeyStore) Lock(addr common.Address) error {
323323
ks.mu.Lock()
324-
if unl, found := ks.unlocked[addr]; found {
325-
ks.mu.Unlock()
324+
unl, found := ks.unlocked[addr]
325+
ks.mu.Unlock()
326+
if found {
326327
ks.expire(addr, unl, time.Duration(0)*time.Nanosecond)
327-
} else {
328-
ks.mu.Unlock()
329328
}
330329
return nil
331330
}

accounts/scwallet/hub.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ func (hub *Hub) readPairings() error {
9696
}
9797
return err
9898
}
99+
defer pairingFile.Close()
99100

100101
pairingData, err := io.ReadAll(pairingFile)
101102
if err != nil {

core/mkalloc.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ func main() {
7575
if err != nil {
7676
panic(err)
7777
}
78+
defer file.Close()
7879
if err := json.NewDecoder(file).Decode(g); err != nil {
7980
panic(err)
8081
}

0 commit comments

Comments
 (0)