Skip to content

Commit 09aecef

Browse files
committed
core: missing nil check, close XFN-114
1 parent d0dcb06 commit 09aecef

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

core/blockchain.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1693,6 +1693,10 @@ func (bc *BlockChain) insertChain(chain types.Blocks, verifySeals bool) (int, []
16931693
var winner []*types.Block
16941694

16951695
parent := bc.GetBlock(block.ParentHash(), block.NumberU64()-1)
1696+
if parent == nil {
1697+
log.Error("[insertChain] fail to get parent block", "number", block.NumberU64()-1, "hash", block.ParentHash())
1698+
return i, events, coalescedLogs, fmt.Errorf("fail to get parent block, number: %v, hash: %v", block.NumberU64()-1, block.ParentHash())
1699+
}
16961700
for !bc.HasFullState(parent) {
16971701
winner = append(winner, parent)
16981702
parent = bc.GetBlock(parent.ParentHash(), parent.NumberU64()-1)

0 commit comments

Comments
 (0)