Safety check in CInstantSend::SyncTransaction (#1412)

This commit is contained in:
UdjinM6 2017-04-11 13:54:34 +03:00 committed by GitHub
parent 5758ae1bfc
commit 68e1a8c790

View File

@ -786,7 +786,17 @@ void CInstantSend::SyncTransaction(const CTransaction& tx, const CBlock* pblock)
uint256 txHash = tx.GetHash(); uint256 txHash = tx.GetHash();
// When tx is 0-confirmed or conflicted, pblock is NULL and nHeightNew should be set to -1 // When tx is 0-confirmed or conflicted, pblock is NULL and nHeightNew should be set to -1
CBlockIndex* pblockindex = pblock ? mapBlockIndex[pblock->GetHash()] : NULL; CBlockIndex* pblockindex = NULL;
if(pblock) {
uint256 blockHash = pblock->GetHash();
BlockMap::iterator mi = mapBlockIndex.find(blockHash);
if(mi == mapBlockIndex.end() || !mi->second) {
// shouldn't happen
LogPrint("instantsend", "CTxLockRequest::SyncTransaction -- Failed to find block %s\n", blockHash.ToString());
return;
}
pblockindex = mi->second;
}
int nHeightNew = pblockindex ? pblockindex->nHeight : -1; int nHeightNew = pblockindex ? pblockindex->nHeight : -1;
LogPrint("instantsend", "CInstantSend::SyncTransaction -- txid=%s nHeightNew=%d\n", txHash.ToString(), nHeightNew); LogPrint("instantsend", "CInstantSend::SyncTransaction -- txid=%s nHeightNew=%d\n", txHash.ToString(), nHeightNew);