eth/downloader: improve nil pointer protection (#32222)

Fix #32221

---------

Co-authored-by: rjl493456442 <garyrong0905@gmail.com>
This commit is contained in:
CertiK-Geth 2025-07-16 21:11:10 +08:00 committed by GitHub
parent 61d7279e1f
commit 532a1c2ca4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 0 deletions

View file

@ -250,6 +250,9 @@ func (d *Downloader) findBeaconAncestor() (uint64, error) {
check := (start + end) / 2
h := d.skeleton.Header(check)
if h == nil {
return 0, fmt.Errorf("filled skeleton header is missing: %d", check)
}
n := h.Number.Uint64()
var known bool

View file

@ -1150,6 +1150,9 @@ func (s *skeleton) cleanStales(filled *types.Header) error {
if number < s.progress.Subchains[0].Head {
// The skeleton chain is partially consumed, set the new tail as filled+1.
tail := rawdb.ReadSkeletonHeader(s.db, number+1)
if tail == nil {
return fmt.Errorf("filled header is missing: %d", number+1)
}
if tail.ParentHash != filled.Hash() {
return fmt.Errorf("filled header is discontinuous with subchain: %d %s, please file an issue", number, filled.Hash())
}