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.
This commit is contained in:
jholdstock 2023-09-05 09:57:43 +01:00 committed by Jamie Holdstock
parent 7d1b7deb01
commit 2af3d4eca7

View File

@ -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.