Skip to content

Commit 95b7973

Browse files
gzliudanliam.lai
authored andcommitted
core: fix missing nil check, close XFN-114 (#1696)
1 parent 91159df commit 95b7973

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
@@ -1703,6 +1703,10 @@ func (bc *BlockChain) insertChain(chain types.Blocks, verifySeals bool) (int, []
17031703
var winner []*types.Block
17041704

17051705
parent := bc.GetBlock(block.ParentHash(), block.NumberU64()-1)
1706+
if parent == nil {
1707+
log.Error("[insertChain] fail to get parent block", "number", block.NumberU64()-1, "hash", block.ParentHash())
1708+
return i, events, coalescedLogs, fmt.Errorf("fail to get parent block, number: %v, hash: %v", block.NumberU64()-1, block.ParentHash())
1709+
}
17061710
for !bc.HasFullState(parent) {
17071711
winner = append(winner, parent)
17081712
parent = bc.GetBlock(parent.ParentHash(), parent.NumberU64()-1)

0 commit comments

Comments
 (0)