diff --git a/src/chain.cpp b/src/chain.cpp index 9cd13d997..7bb72d5d3 100644 --- a/src/chain.cpp +++ b/src/chain.cpp @@ -81,7 +81,8 @@ CBlockIndex* CBlockIndex::GetAncestor(int height) CBlockIndex* pindexWalk = this; int heightWalk = nHeight; - while (heightWalk > height) { + while ( heightWalk > height && pindexWalk != 0 ) + { int heightSkip = GetSkipHeight(heightWalk); int heightSkipPrev = GetSkipHeight(heightWalk - 1); if (pindexWalk->pskip != NULL &&