Skip to content

Commit

Permalink
Fix Panic: Check For Error Before Defer (#482)
Browse files Browse the repository at this point in the history
## 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
  • Loading branch information
Kbhat1 authored and udpatil committed Apr 19, 2024
1 parent 1bd5300 commit 771a3fd
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion storev2/rootmulti/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -507,10 +507,10 @@ func (rs *Store) Query(req abci.RequestQuery) abci.ResponseQuery {
} else {
// Serve abci query from historical sc store if proofs needed
scStore, err := rs.scStore.LoadVersion(version, true)
defer scStore.Close()
if err != nil {
return sdkerrors.QueryResult(err)
}
defer scStore.Close()
store = types.Queryable(commitment.NewStore(scStore.GetTreeByName(storeName), rs.logger))
commitInfo = convertCommitInfo(scStore.LastCommitInfo())
commitInfo = amendCommitInfo(commitInfo, rs.storesParams)
Expand Down

0 comments on commit 771a3fd

Please sign in to comment.