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:
Jonny Rhea 2026-08-04 01:16:45 -05:00 committed by GitHub
parent 5131c031dd
commit b483fe9e71
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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