mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-03-28 22:02:55 +00:00
core/state: add bounds check in heap eviction loop (#33712)
core/state: add bounds check in heap eviction loop Add len(h) > 0 check before accessing h[0] to prevent potential panic and align with existing heap access patterns in txpool, p2p, and mclock packages.
This commit is contained in:
parent
c974722dc0
commit
a179ccf6f0
1 changed files with 1 additions and 1 deletions
|
|
@ -346,7 +346,7 @@ func (t *SizeTracker) run() {
|
|||
|
||||
// Evict the stale statistics
|
||||
heap.Push(&h, stats[u.root])
|
||||
for u.blockNumber-h[0].BlockNumber > statEvictThreshold {
|
||||
for len(h) > 0 && u.blockNumber-h[0].BlockNumber > statEvictThreshold {
|
||||
delete(stats, h[0].StateRoot)
|
||||
heap.Pop(&h)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue