From 758100252385068f960bfce4cbddbf7f0a0d2f7f Mon Sep 17 00:00:00 2001 From: Matt Smith Date: Mon, 14 Jan 2019 17:54:47 -0500 Subject: [PATCH] Fix segfault on DGW --- src/pow.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/pow.cpp b/src/pow.cpp index 7d908523c..4e6adb4d8 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -18,9 +18,8 @@ unsigned int static DarkGravityWave(const CBlockIndex* pindexLast, const CBlockH int64_t nPastBlocks = 24; // make sure we have at least (nPastBlocks + 1) blocks, otherwise just return powLimit - if (!pblock || !pindexLast || pindexLast->nHeight < nPastBlocks) { + if (pblock == nullptr || pindexLast == nullptr || pindexLast->nHeight < nPastBlocks) return bnPowLimit.GetCompact(); - } if (params.fPowAllowMinDifficultyBlocks) { // recent block is more than 2 hours old @@ -56,6 +55,9 @@ unsigned int static DarkGravityWave(const CBlockIndex* pindexLast, const CBlockH arith_uint256 bnNew(bnPastTargetAvg); + if(pindex == nullptr || pindexLast == nullptr) + return bnPowLimit.GetCompact(); + int64_t nActualTimespan = pindexLast->GetBlockTime() - pindex->GetBlockTime(); // NOTE: is this accurate? nActualTimespan counts it for (nPastBlocks - 1) blocks only... int64_t nTargetTimespan = nPastBlocks * params.nPowTargetSpacing * NUM_ALGOS;