Skip to content

Commit 6f71ccb

Browse files
Kbhat1udpatil
authored andcommitted
Fix Panic: Check For Error Before Defer (#482)
## Describe your changes and provide context - Checks for err before `defer` - Without this, if there is a err, the node will panic on the `defer` because `scStore` is `nil` ## Testing performed to validate your change - Verified on node
1 parent 473900f commit 6f71ccb

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

storev2/rootmulti/store.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -507,10 +507,10 @@ func (rs *Store) Query(req abci.RequestQuery) abci.ResponseQuery {
507507
} else {
508508
// Serve abci query from historical sc store if proofs needed
509509
scStore, err := rs.scStore.LoadVersion(version, true)
510-
defer scStore.Close()
511510
if err != nil {
512511
return sdkerrors.QueryResult(err)
513512
}
513+
defer scStore.Close()
514514
store = types.Queryable(commitment.NewStore(scStore.GetTreeByName(storeName), rs.logger))
515515
commitInfo = convertCommitInfo(scStore.LastCommitInfo())
516516
commitInfo = amendCommitInfo(commitInfo, rs.storesParams)

0 commit comments

Comments
 (0)