diff --git a/accounts/keystore/keystore.go b/accounts/keystore/keystore.go index 32580d01c1..983793e0b7 100644 --- a/accounts/keystore/keystore.go +++ b/accounts/keystore/keystore.go @@ -323,11 +323,10 @@ func (ks *KeyStore) Unlock(a accounts.Account, passphrase string) error { // Lock removes the private key with the given address from memory. func (ks *KeyStore) Lock(addr common.Address) error { ks.mu.Lock() - if unl, found := ks.unlocked[addr]; found { - ks.mu.Unlock() + unl, found := ks.unlocked[addr] + ks.mu.Unlock() + if found { ks.expire(addr, unl, time.Duration(0)*time.Nanosecond) - } else { - ks.mu.Unlock() } return nil } diff --git a/accounts/scwallet/hub.go b/accounts/scwallet/hub.go index 50b5433765..410e8f0023 100644 --- a/accounts/scwallet/hub.go +++ b/accounts/scwallet/hub.go @@ -95,6 +95,7 @@ func (hub *Hub) readPairings() error { } return err } + defer pairingFile.Close() pairingData, err := io.ReadAll(pairingFile) if err != nil { diff --git a/core/mkalloc.go b/core/mkalloc.go index 6c8a5d0ee5..0eb2e86e2d 100644 --- a/core/mkalloc.go +++ b/core/mkalloc.go @@ -78,6 +78,7 @@ func main() { if err != nil { panic(err) } + defer file.Close() if err := json.NewDecoder(file).Decode(g); err != nil { panic(err) }