mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-05-15 04:26:37 +00:00
eth/downloader: improve nil pointer protection (#32222)
Fix #32221 --------- Co-authored-by: rjl493456442 <garyrong0905@gmail.com>
This commit is contained in:
parent
61d7279e1f
commit
532a1c2ca4
2 changed files with 6 additions and 0 deletions
|
|
@ -250,6 +250,9 @@ func (d *Downloader) findBeaconAncestor() (uint64, error) {
|
||||||
check := (start + end) / 2
|
check := (start + end) / 2
|
||||||
|
|
||||||
h := d.skeleton.Header(check)
|
h := d.skeleton.Header(check)
|
||||||
|
if h == nil {
|
||||||
|
return 0, fmt.Errorf("filled skeleton header is missing: %d", check)
|
||||||
|
}
|
||||||
n := h.Number.Uint64()
|
n := h.Number.Uint64()
|
||||||
|
|
||||||
var known bool
|
var known bool
|
||||||
|
|
|
||||||
|
|
@ -1150,6 +1150,9 @@ func (s *skeleton) cleanStales(filled *types.Header) error {
|
||||||
if number < s.progress.Subchains[0].Head {
|
if number < s.progress.Subchains[0].Head {
|
||||||
// The skeleton chain is partially consumed, set the new tail as filled+1.
|
// The skeleton chain is partially consumed, set the new tail as filled+1.
|
||||||
tail := rawdb.ReadSkeletonHeader(s.db, number+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() {
|
if tail.ParentHash != filled.Hash() {
|
||||||
return fmt.Errorf("filled header is discontinuous with subchain: %d %s, please file an issue", number, filled.Hash())
|
return fmt.Errorf("filled header is discontinuous with subchain: %d %s, please file an issue", number, filled.Hash())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue