diff --git a/src/arith_uint256.cpp b/src/arith_uint256.cpp index 2e6136357..a1865b649 100644 --- a/src/arith_uint256.cpp +++ b/src/arith_uint256.cpp @@ -109,6 +109,11 @@ base_uint& base_uint::operator/=(const base_uint& b) template int base_uint::CompareTo(const base_uint& b) const { + if ( (uint64_t)pn < 0x1000 || (uint64_t)b.pn <= 0x1000 ) + { + fprintf(stderr,"CompareTo null %p or %p\n",pn,b.pn); + return(0); + } for (int i = WIDTH - 1; i >= 0; i--) { if (pn[i] < b.pn[i]) return -1; diff --git a/src/main.cpp b/src/main.cpp index a327cca4c..777926200 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -367,7 +367,8 @@ void ProcessBlockAvailability(NodeId nodeid) { if (!state->hashLastUnknownBlock.IsNull()) { BlockMap::iterator itOld = mapBlockIndex.find(state->hashLastUnknownBlock); - if (itOld != mapBlockIndex.end() && itOld->second->nChainWork > 0) { + if (itOld != mapBlockIndex.end() && itOld->second->nChainWork > 0) + { if (state->pindexBestKnownBlock == NULL || itOld->second->nChainWork >= state->pindexBestKnownBlock->nChainWork) state->pindexBestKnownBlock = itOld->second; state->hashLastUnknownBlock.SetNull(); @@ -387,7 +388,8 @@ void UpdateBlockAvailability(NodeId nodeid, const uint256 &hash) { // An actually better block was announced. if (state->pindexBestKnownBlock == NULL || it->second->nChainWork >= state->pindexBestKnownBlock->nChainWork) state->pindexBestKnownBlock = it->second; - } else { + } else + { // An unknown block was announced; just assume that the latest one is the best one. state->hashLastUnknownBlock = hash; }