@@ -2220,9 +2220,12 @@ bool BitcoindRPCCheck(const bool init)
22202220 pblocktree->ReadInvalidBlockQueue (vblocksToReconsider);
22212221 std::vector<uint256> vblocksToReconsiderAgain;
22222222 BOOST_FOREACH (uint256& blockhash, vblocksToReconsider) {
2223- CBlockIndex* pblockindex = mapBlockIndex[blockhash];
2224- if ((pblockindex->nStatus & BLOCK_FAILED_MASK)) {
2225- vblocksToReconsiderAgain.push_back (blockhash);
2223+ LOCK (cs_main);
2224+ if (mapBlockIndex.count (blockhash)) {
2225+ CBlockIndex* pblockindex = mapBlockIndex[blockhash];
2226+ if ((pblockindex->nStatus & BLOCK_FAILED_MASK)) {
2227+ vblocksToReconsiderAgain.push_back (blockhash);
2228+ }
22262229 }
22272230 }
22282231 vblocksToReconsider = vblocksToReconsiderAgain;
@@ -2312,11 +2315,14 @@ bool BitcoindRPCCheck(const bool init)
23122315
23132316 // Now to clear out now-valid blocks
23142317 BOOST_FOREACH (const uint256& blockhash, vblocksToReconsider) {
2315- CBlockIndex* pblockindex = mapBlockIndex[blockhash];
2318+ LOCK (cs_main);
2319+ if (mapBlockIndex.count (blockhash)) {
2320+ CBlockIndex* pblockindex = mapBlockIndex[blockhash];
23162321
2317- // Marked as invalid still, put back into queue
2318- if ((pblockindex->nStatus & BLOCK_FAILED_MASK)) {
2319- vblocksToReconsiderAgain.push_back (blockhash);
2322+ // Marked as invalid still, put back into queue
2323+ if ((pblockindex->nStatus & BLOCK_FAILED_MASK)) {
2324+ vblocksToReconsiderAgain.push_back (blockhash);
2325+ }
23202326 }
23212327 }
23222328
0 commit comments