From a179ccf6f002024268d524a4254abb0011f3d964 Mon Sep 17 00:00:00 2001 From: Noisy <125606576+donatik27@users.noreply.github.com> Date: Thu, 29 Jan 2026 14:08:04 +0100 Subject: [PATCH] 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. --- core/state/state_sizer.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/state/state_sizer.go b/core/state/state_sizer.go index fc6781ad93..02b73e5575 100644 --- a/core/state/state_sizer.go +++ b/core/state/state_sizer.go @@ -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) }