Skip to content

Commit 11f2e4f

Browse files
committed
fix: avoid possible nullptr for unknown hash of qc after LookupBlockIndex
1 parent b4999d7 commit 11f2e4f

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/llmq/blockprocessor.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,11 @@ bool CQuorumBlockProcessor::ProcessBlock(const CBlock& block, gsl::not_null<cons
219219
for (const auto& [_, qc] : qcs) {
220220
if (qc.IsNull()) continue;
221221
const auto* pQuorumBaseBlockIndex = m_chainstate.m_blockman.LookupBlockIndex(qc.quorumHash);
222+
if (pQuorumBaseBlockIndex == nullptr) {
223+
LogPrint(BCLog::LLMQ, "[ProcessBlock] h[%d] unexpectedly failed due to no known pindex for hash[%s]\n",
224+
pindex->nHeight, qc.quorumHash.ToString());
225+
return false;
226+
}
222227
qc.VerifySignatureAsync(m_dmnman, m_qsnapman, pQuorumBaseBlockIndex, &queue_control);
223228
}
224229

@@ -334,6 +339,11 @@ bool CQuorumBlockProcessor::ProcessCommitment(int nHeight, const uint256& blockH
334339
}
335340

336341
const auto* pQuorumBaseBlockIndex = m_chainstate.m_blockman.LookupBlockIndex(qc.quorumHash);
342+
if (pQuorumBaseBlockIndex == nullptr) {
343+
LogPrint(BCLog::LLMQ, "%s -- unexpectedly failed due to no known pindex for hash[%s]\n",
344+
__func__, qc.quorumHash.ToString());
345+
return false;
346+
}
337347

338348
// we don't validate signatures here; they already validated on previous step
339349
if (!qc.Verify(m_dmnman, m_qsnapman, pQuorumBaseBlockIndex, /*checksigs=*/false)) {

0 commit comments

Comments
 (0)