mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-05 03:23:46 +00:00
eth/syncer: fix nil deref when the target block is missing (#35442)
i didn't try to trigger the nil deref, but fixing it shouldn't be controversial
This commit is contained in:
parent
5131c031dd
commit
b483fe9e71
1 changed files with 4 additions and 3 deletions
|
|
@ -180,9 +180,10 @@ func (s *Syncer) run() {
|
|||
var synced bool
|
||||
var block *types.Header
|
||||
if target != nil {
|
||||
tb := s.backend.BlockChain().GetBlockByHash(target.Hash())
|
||||
synced = tb != nil
|
||||
block = tb.Header()
|
||||
if tb := s.backend.BlockChain().GetBlockByHash(target.Hash()); tb != nil {
|
||||
synced = true
|
||||
block = tb.Header()
|
||||
}
|
||||
} else {
|
||||
timestamp := time.Unix(int64(ev.Latest.Time), 0)
|
||||
synced = time.Since(timestamp) < 10*time.Minute
|
||||
|
|
|
|||
Loading…
Reference in a new issue