From 2af3d4eca71bd65a1ca437b554853b69c85a45a3 Mon Sep 17 00:00:00 2001 From: jholdstock Date: Tue, 5 Sep 2023 09:57:43 +0100 Subject: [PATCH] vspd: Fix OOB panic in spent ticket scanner. Range expressions are only evaluated once before beginning a for loop, which makes them unsuitable for loops which manually alter the index. --- cmd/vspd/spentticket.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/vspd/spentticket.go b/cmd/vspd/spentticket.go index f4c156f..95ef8eb 100644 --- a/cmd/vspd/spentticket.go +++ b/cmd/vspd/spentticket.go @@ -146,7 +146,7 @@ func (v *vspd) findSpentTickets(toCheck database.TicketList, startHeight int64) return nil, 0, err } - for i := range tickets { + for i := 0; i < len(tickets); i++ { // The regular transaction tree does not need to be checked because // tickets can only be spent by vote or revoke transactions which // are always in the stake tree.