Fix null access

This commit is contained in:
jl777
2019-08-01 10:01:55 -11:00
parent 63a95a2005
commit 61e4db4332

View File

@@ -75,14 +75,14 @@ unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHead
const CBlockIndex* pindexFirst = pindexLast;
arith_uint256 bnTarget,bnTot {0};
uint32_t nbits; int64_t diff,mult = 0;
if ( pindexFirst != 0 )
if ( pindexFirst != 0 && pblock != 0 )
mult = pblock->nTime - pindexFirst->nTime - 7 * ASSETCHAINS_BLOCKTIME;
for (int i = 0; pindexFirst && i < params.nPowAveragingWindow; i++)
{
arith_uint256 bnTmp;
bnTmp.SetCompact(pindexFirst->nBits);
bnTot += bnTmp;
if ( ASSETCHAINS_ADAPTIVEPOW > 0 && i < 12 )
if ( ASSETCHAINS_ADAPTIVEPOW > 0 && i < 12 && pblock != 0 )
{
diff = pblock->nTime - pindexFirst->nTime - (8+i)*ASSETCHAINS_BLOCKTIME;
if ( diff > mult )