From 1540ad932d556211a0321b8120255d8758f47d17 Mon Sep 17 00:00:00 2001 From: zjubfd <296179868@qq.com> Date: Mon, 6 Sep 2021 10:37:16 +0800 Subject: [PATCH] fix nil point in downloader (#409) --- eth/downloader/downloader.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/eth/downloader/downloader.go b/eth/downloader/downloader.go index 6f59b29a5..3dee90c42 100644 --- a/eth/downloader/downloader.go +++ b/eth/downloader/downloader.go @@ -985,6 +985,10 @@ func (d *Downloader) findAncestorBinarySearch(p *peerConnection, mode SyncMode, break } header := d.lightchain.GetHeaderByHash(h) // Independent of sync mode, header surely exists + if header == nil { + p.log.Error("header not found", "number", header.Number, "hash", header.Hash(), "request", check) + return 0, fmt.Errorf("%w: header no found (%d)", errBadPeer, header.Number) + } if header.Number.Uint64() != check { p.log.Warn("Received non requested header", "number", header.Number, "hash", header.Hash(), "request", check) return 0, fmt.Errorf("%w: non-requested header (%d)", errBadPeer, header.Number)