Skip to content

Commit f66c7a9

Browse files
PastaPastaPastaknst
authored andcommitted
Merge dashpay#6789: fix: avoid possible nullptr for unknown hash of qc after LookupBlockIndex
3b9e061 fix: handle possible nullptr in InitNewQuorum (Konstantin Akimov) c7890b7 fix: avoid possible nullptr for unknown hash of qc after LookupBlockIndex (Konstantin Akimov) Pull request description: ## Issue being fixed or feature implemented Follow-up for dashpay#6692; discovered possible nullptr usage after looking for non-existing block ## What was done? Added extra check for nullptr in 3 missing places in dash specific code: - CDKGSessionHandler::HandleDKGRound - CQuorumBlockProcessor::ProcessBlock - CQuorumBlockProcessor::ProcessCommitment ## How Has This Been Tested? N/A ## Breaking Changes N/A ## Checklist: - [x] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have added or updated relevant unit/integration/functional/e2e tests - [ ] I have made corresponding changes to the documentation - [x] I have assigned this pull request to a milestone _(for repository code-owners and collaborators only)_ ACKs for top commit: UdjinM6: utACK 3b9e061 Tree-SHA512: 3e5fa925250efa0e272c25f39d833c8fd1e51f1b9a338a63e8940dadfb91c61933eb48196f588621fdda3106fb887bd311dd01c287549720adb6124503e26b79
1 parent 2123e9f commit f66c7a9

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/llmq/blockprocessor.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,11 @@ bool CQuorumBlockProcessor::ProcessCommitment(int nHeight, const uint256& blockH
272272
}
273273

274274
const auto* pQuorumBaseBlockIndex = m_chainstate.m_blockman.LookupBlockIndex(qc.quorumHash);
275+
if (pQuorumBaseBlockIndex == nullptr) {
276+
LogPrint(BCLog::LLMQ, "%s -- unexpectedly failed due to no known pindex for hash[%s]\n", __func__,
277+
qc.quorumHash.ToString());
278+
return false;
279+
}
275280

276281
if (!qc.Verify(m_dmnman, m_qsnapman, pQuorumBaseBlockIndex, /*checkSigs=*/fBLSChecks)) {
277282
LogPrint(BCLog::LLMQ, "CQuorumBlockProcessor::%s height=%d, type=%d, quorumIndex=%d, quorumHash=%s, signers=%s, validMembers=%d, quorumPublicKey=%s qc verify failed.\n", __func__,

src/llmq/dkgsessionhandler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ void CDKGSessionHandler::HandleDKGRound(CConnman& connman, PeerManager& peerman)
537537

538538
const CBlockIndex* pQuorumBaseBlockIndex = WITH_LOCK(cs_main, return m_chainstate.m_blockman.LookupBlockIndex(curQuorumHash));
539539

540-
if (!InitNewQuorum(pQuorumBaseBlockIndex)) {
540+
if (!pQuorumBaseBlockIndex || !InitNewQuorum(pQuorumBaseBlockIndex)) {
541541
// should actually never happen
542542
WaitForNewQuorum(curQuorumHash);
543543
throw AbortPhaseException();

0 commit comments

Comments
 (0)