Skip to content

Commit

Permalink
prevent nil memory access by checking tx status before fetching receipt
Browse files Browse the repository at this point in the history
  • Loading branch information
beer-1 committed Dec 9, 2024
1 parent 55ab7cf commit 58b076d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions jsonrpc/backend/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,8 @@ func (b *JSONRPCBackend) GetTransactionReceipt(hash common.Hash) (map[string]int
rpcTx, err := b.getTransaction(hash)
if err != nil {
return nil, err
} else if rpcTx == nil {
return nil, nil // tx is not found
} else if rpcTx == nil || rpcTx.BlockNumber == nil || rpcTx.BlockNumber.ToInt() == nil {
return nil, nil // tx is not found or in pending/queued state

Check warning on line 188 in jsonrpc/backend/tx.go

View check run for this annotation

Codecov / codecov/patch

jsonrpc/backend/tx.go#L188

Added line #L188 was not covered by tests
}

receipt, err := b.getReceipt(hash)
Expand Down

0 comments on commit 58b076d

Please sign in to comment.