Fix a panic caused by accessing unassigned pointer
This bug was introduced with the fix for checkBlockForHidden votes. One of the consistency checks fails if the template is uninitialized. The unitialized pointer is now caught and the function will safely return.
This commit is contained in:
parent
3a30ba7695
commit
61dd0bce67
@ -946,7 +946,6 @@ func (b *blockManager) checkBlockForHiddenVotes(block *dcrutil.Block) {
|
||||
// the parent template hasn't yet been updated, so we may
|
||||
// need to use the current template.
|
||||
var template *BlockTemplate
|
||||
|
||||
if b.cachedCurrentTemplate != nil {
|
||||
if b.cachedCurrentTemplate.height ==
|
||||
block.Height() {
|
||||
@ -961,6 +960,11 @@ func (b *blockManager) checkBlockForHiddenVotes(block *dcrutil.Block) {
|
||||
}
|
||||
}
|
||||
|
||||
// No template to alter.
|
||||
if template == nil {
|
||||
return
|
||||
}
|
||||
|
||||
// Make sure that the template has the same parent
|
||||
// as the new block.
|
||||
if template.block.Header.PrevBlock !=
|
||||
@ -1011,9 +1015,6 @@ func (b *blockManager) checkBlockForHiddenVotes(block *dcrutil.Block) {
|
||||
newVotes = append(newVotes, vote)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// We have no template, so nothing to update.
|
||||
return
|
||||
}
|
||||
|
||||
// Check the length of the reconstructed voter list for
|
||||
|
||||
Loading…
Reference in New Issue
Block a user