From c4b670009db16f2ea7ed3f86b4cdcf17f92972b8 Mon Sep 17 00:00:00 2001 From: William Banfield Date: Wed, 12 Jan 2022 17:11:44 -0500 Subject: [PATCH] fix nil pointer panic --- types/vote_set.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/types/vote_set.go b/types/vote_set.go index 5c29e3d34..c416a58cb 100644 --- a/types/vote_set.go +++ b/types/vote_set.go @@ -380,6 +380,9 @@ func (voteSet *VoteSet) GetByIndex(valIndex int32) *Vote { // List returns a copy of the list of votes stored by the VoteSet. func (voteSet *VoteSet) List() []Vote { + if voteSet == nil { + return nil + } votes := make([]Vote, len(voteSet.votes)) for i := range voteSet.votes { votes[i] = *voteSet.votes[i] @@ -432,6 +435,9 @@ func (voteSet *VoteSet) HasTwoThirdsAny() bool { } func (voteSet *VoteSet) HasAll() bool { + if voteSet == nil { + return false + } voteSet.mtx.Lock() defer voteSet.mtx.Unlock() return voteSet.sum == voteSet.valSet.TotalVotingPower()