mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-15 16:33:47 +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 synced bool
|
||||||
var block *types.Header
|
var block *types.Header
|
||||||
if target != nil {
|
if target != nil {
|
||||||
tb := s.backend.BlockChain().GetBlockByHash(target.Hash())
|
if tb := s.backend.BlockChain().GetBlockByHash(target.Hash()); tb != nil {
|
||||||
synced = tb != nil
|
synced = true
|
||||||
block = tb.Header()
|
block = tb.Header()
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
timestamp := time.Unix(int64(ev.Latest.Time), 0)
|
timestamp := time.Unix(int64(ev.Latest.Time), 0)
|
||||||
synced = time.Since(timestamp) < 10*time.Minute
|
synced = time.Since(timestamp) < 10*time.Minute
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue