Skip to content

Commit b455148

Browse files
committed
fix: avoid possible nullptr for unknown hash of qc after LookupBlockIndex
1 parent c047c58 commit b455148

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/llmq/blockprocessor.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,10 @@ bool CQuorumBlockProcessor::ProcessBlock(const CBlock& block, gsl::not_null<cons
217217
for (const auto& [_, qc] : qcs) {
218218
if (qc.IsNull()) continue;
219219
const auto* pQuorumBaseBlockIndex = m_chainstate.m_blockman.LookupBlockIndex(qc.quorumHash);
220+
if (pQuorumBaseBlockIndex == nullptr) {
221+
LogPrint(BCLog::LLMQ, "[ProcessBlock] failed due to no known pindex for hash[%s]\n", qc.quorumHash.ToString());
222+
return false;
223+
}
220224
qc.VerifySignatureAsync(m_dmnman, m_qsnapman, pQuorumBaseBlockIndex, &queue_control);
221225
}
222226

@@ -304,6 +308,10 @@ bool CQuorumBlockProcessor::ProcessCommitment(int nHeight, const uint256& blockH
304308
}
305309

306310
const auto* pQuorumBaseBlockIndex = m_chainstate.m_blockman.LookupBlockIndex(qc.quorumHash);
311+
if (pQuorumBaseBlockIndex == nullptr) {
312+
LogPrint(BCLog::LLMQ, "CQuorumBlockProcessor::%s failed due to no known pindex for hash[%s]\n", qc.quorumHash.ToString());
313+
return false;
314+
}
307315

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

0 commit comments

Comments
 (0)