From: svost Date: Thu, 31 Mar 2016 15:38:13 +0000 (+0300) Subject: Fix pointer to local variable logic (V506 PVS Studio) X-Git-Tag: nvc-v0.5.8~15^2^2 X-Git-Url: https://git.novaco.in/?p=novacoin.git;a=commitdiff_plain;h=2d6690cc0c0e2525996856c392566133d1b2de50 Fix pointer to local variable logic (V506 PVS Studio) --- diff --git a/src/main.cpp b/src/main.cpp index 660bb41..4b7bb9a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -445,7 +445,6 @@ CTransaction::GetLegacySigOpCount() const return nSigOps; } - int CMerkleTx::SetMerkleBranch(const CBlock* pblock) { if (fClient) @@ -456,16 +455,6 @@ int CMerkleTx::SetMerkleBranch(const CBlock* pblock) else { CBlock blockTmp; - if (pblock == NULL) - { - // Load the block this tx is in - CTxIndex txindex; - if (!CTxDB("r").ReadTxIndex(GetHash(), txindex)) - return 0; - if (!blockTmp.ReadFromDisk(txindex.pos.nFile, txindex.pos.nBlockPos)) - return 0; - pblock = &blockTmp; - } // Update the tx's hashBlock hashBlock = pblock->GetHash(); @@ -490,19 +479,13 @@ int CMerkleTx::SetMerkleBranch(const CBlock* pblock) map::iterator mi = mapBlockIndex.find(hashBlock); if (mi == mapBlockIndex.end()) return 0; - CBlockIndex* pindex = (*mi).second; + const CBlockIndex* pindex = (*mi).second; if (!pindex || !pindex->IsInMainChain()) return 0; return pindexBest->nHeight - pindex->nHeight + 1; } - - - - - - bool CTransaction::CheckTransaction() const { // Basic checks that don't depend on any context diff --git a/src/main.h b/src/main.h index df49707..cb7650c 100644 --- a/src/main.h +++ b/src/main.h @@ -794,7 +794,7 @@ public: ) - int SetMerkleBranch(const CBlock* pblock=NULL); + int SetMerkleBranch(const CBlock* pblock); int GetDepthInMainChain(CBlockIndex* &pindexRet) const; int GetDepthInMainChain() const { CBlockIndex *pindexRet; return GetDepthInMainChain(pindexRet); } bool IsInMainChain() const { return GetDepthInMainChain() > 0; }