From 3c40a9a667424a164522e17ec18d810d53d7677d Mon Sep 17 00:00:00 2001 From: Michael Toutonghi Date: Fri, 10 Aug 2018 17:21:41 -0700 Subject: [PATCH] Fail on get_chainactive before lock if checks fail --- src/miner.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index f31d6bd7c..908fd601f 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -813,11 +813,13 @@ int32_t waitForPeers(const CChainParams &chainparams) #ifdef ENABLE_WALLET CBlockIndex *get_chainactive(int32_t height) { - LOCK(cs_main); - if ( chainActive.Tip() != 0 ) + if ( chainActive.LastTip() != 0 ) { - if ( height <= chainActive.Tip()->nHeight ) + if ( height <= chainActive.LastTip()->nHeight ) + { + LOCK(cs_main); return(chainActive[height]); + } // else fprintf(stderr,"get_chainactive height %d > active.%d\n",height,chainActive.Tip()->nHeight); } //fprintf(stderr,"get_chainactive null chainActive.Tip() height %d\n",height);