mirror of
https://github.com/kvazar-network/kevacoin.git
synced 2025-01-20 12:00:52 +00:00
Merge #10898: Fix invalid checks (NULL checks after dereference, redundant checks, etc.)
76fed83 Avoid NULL pointer dereference when _walletModel is NULL (which is valid) (practicalswift) 4971a9a Use two boolean literals instead of re-using variable (practicalswift) b5fb339 Remove duplicate uriParts.size() > 0 check (practicalswift) 7466991 Remove redundant check (!ecc is always true) (practicalswift) 55224af Remove redundant NULL checks after new (practicalswift) Pull request description: Contains: * Remove redundant `NULL` checks after throwing `new` * Remove redundant check (`!ecc` is always true) * Remove duplicate `uriParts.size() > 0` check * Use two boolean literals instead of re-using variable Tree-SHA512: 30e9af8a9d5c8184836f8267b492aeb4e26eca171a3be08f634b3f39b3055b9fa9f06623f6c69b294ca13bf99743f7645cfac2b25e014ff74687bd085a997895
This commit is contained in:
commit
470c730e3f
@ -690,10 +690,10 @@ static void MutateTx(CMutableTransaction& tx, const std::string& command,
|
|||||||
else if (command == "outaddr")
|
else if (command == "outaddr")
|
||||||
MutateTxAddOutAddr(tx, commandVal);
|
MutateTxAddOutAddr(tx, commandVal);
|
||||||
else if (command == "outpubkey") {
|
else if (command == "outpubkey") {
|
||||||
if (!ecc) { ecc.reset(new Secp256k1Init()); }
|
ecc.reset(new Secp256k1Init());
|
||||||
MutateTxAddOutPubKey(tx, commandVal);
|
MutateTxAddOutPubKey(tx, commandVal);
|
||||||
} else if (command == "outmultisig") {
|
} else if (command == "outmultisig") {
|
||||||
if (!ecc) { ecc.reset(new Secp256k1Init()); }
|
ecc.reset(new Secp256k1Init());
|
||||||
MutateTxAddOutMultiSig(tx, commandVal);
|
MutateTxAddOutMultiSig(tx, commandVal);
|
||||||
} else if (command == "outscript")
|
} else if (command == "outscript")
|
||||||
MutateTxAddOutScript(tx, commandVal);
|
MutateTxAddOutScript(tx, commandVal);
|
||||||
@ -701,7 +701,7 @@ static void MutateTx(CMutableTransaction& tx, const std::string& command,
|
|||||||
MutateTxAddOutData(tx, commandVal);
|
MutateTxAddOutData(tx, commandVal);
|
||||||
|
|
||||||
else if (command == "sign") {
|
else if (command == "sign") {
|
||||||
if (!ecc) { ecc.reset(new Secp256k1Init()); }
|
ecc.reset(new Secp256k1Init());
|
||||||
MutateTxSign(tx, commandVal);
|
MutateTxSign(tx, commandVal);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -379,19 +379,17 @@ void MaybeSetPeerAsAnnouncingHeaderAndIDs(NodeId nodeid, CConnman* connman) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
connman->ForNode(nodeid, [connman](CNode* pfrom){
|
connman->ForNode(nodeid, [connman](CNode* pfrom){
|
||||||
bool fAnnounceUsingCMPCTBLOCK = false;
|
|
||||||
uint64_t nCMPCTBLOCKVersion = (pfrom->GetLocalServices() & NODE_WITNESS) ? 2 : 1;
|
uint64_t nCMPCTBLOCKVersion = (pfrom->GetLocalServices() & NODE_WITNESS) ? 2 : 1;
|
||||||
if (lNodesAnnouncingHeaderAndIDs.size() >= 3) {
|
if (lNodesAnnouncingHeaderAndIDs.size() >= 3) {
|
||||||
// As per BIP152, we only get 3 of our peers to announce
|
// As per BIP152, we only get 3 of our peers to announce
|
||||||
// blocks using compact encodings.
|
// blocks using compact encodings.
|
||||||
connman->ForNode(lNodesAnnouncingHeaderAndIDs.front(), [connman, fAnnounceUsingCMPCTBLOCK, nCMPCTBLOCKVersion](CNode* pnodeStop){
|
connman->ForNode(lNodesAnnouncingHeaderAndIDs.front(), [connman, nCMPCTBLOCKVersion](CNode* pnodeStop){
|
||||||
connman->PushMessage(pnodeStop, CNetMsgMaker(pnodeStop->GetSendVersion()).Make(NetMsgType::SENDCMPCT, fAnnounceUsingCMPCTBLOCK, nCMPCTBLOCKVersion));
|
connman->PushMessage(pnodeStop, CNetMsgMaker(pnodeStop->GetSendVersion()).Make(NetMsgType::SENDCMPCT, /*fAnnounceUsingCMPCTBLOCK=*/false, nCMPCTBLOCKVersion));
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
lNodesAnnouncingHeaderAndIDs.pop_front();
|
lNodesAnnouncingHeaderAndIDs.pop_front();
|
||||||
}
|
}
|
||||||
fAnnounceUsingCMPCTBLOCK = true;
|
connman->PushMessage(pfrom, CNetMsgMaker(pfrom->GetSendVersion()).Make(NetMsgType::SENDCMPCT, /*fAnnounceUsingCMPCTBLOCK=*/true, nCMPCTBLOCKVersion));
|
||||||
connman->PushMessage(pfrom, CNetMsgMaker(pfrom->GetSendVersion()).Make(NetMsgType::SENDCMPCT, fAnnounceUsingCMPCTBLOCK, nCMPCTBLOCKVersion));
|
|
||||||
lNodesAnnouncingHeaderAndIDs.push_back(pfrom->GetId());
|
lNodesAnnouncingHeaderAndIDs.push_back(pfrom->GetId());
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
@ -122,8 +122,8 @@ void WalletView::setWalletModel(WalletModel *_walletModel)
|
|||||||
overviewPage->setWalletModel(_walletModel);
|
overviewPage->setWalletModel(_walletModel);
|
||||||
receiveCoinsPage->setModel(_walletModel);
|
receiveCoinsPage->setModel(_walletModel);
|
||||||
sendCoinsPage->setModel(_walletModel);
|
sendCoinsPage->setModel(_walletModel);
|
||||||
usedReceivingAddressesPage->setModel(_walletModel->getAddressTableModel());
|
usedReceivingAddressesPage->setModel(_walletModel ? _walletModel->getAddressTableModel() : nullptr);
|
||||||
usedSendingAddressesPage->setModel(_walletModel->getAddressTableModel());
|
usedSendingAddressesPage->setModel(_walletModel ? _walletModel->getAddressTableModel() : nullptr);
|
||||||
|
|
||||||
if (_walletModel)
|
if (_walletModel)
|
||||||
{
|
{
|
||||||
|
@ -409,10 +409,8 @@ static bool rest_getutxos(HTTPRequest* req, const std::string& strURIPart)
|
|||||||
|
|
||||||
if (uriParts.size() > 0)
|
if (uriParts.size() > 0)
|
||||||
{
|
{
|
||||||
|
|
||||||
//inputs is sent over URI scheme (/rest/getutxos/checkmempool/txid1-n/txid2-n/...)
|
//inputs is sent over URI scheme (/rest/getutxos/checkmempool/txid1-n/txid2-n/...)
|
||||||
if (uriParts.size() > 0 && uriParts[0] == "checkmempool")
|
if (uriParts[0] == "checkmempool") fCheckMemPool = true;
|
||||||
fCheckMemPool = true;
|
|
||||||
|
|
||||||
for (size_t i = (fCheckMemPool) ? 1 : 0; i < uriParts.size(); i++)
|
for (size_t i = (fCheckMemPool) ? 1 : 0; i < uriParts.size(); i++)
|
||||||
{
|
{
|
||||||
|
@ -2613,7 +2613,6 @@ static CBlockIndex* AddToBlockIndex(const CBlockHeader& block)
|
|||||||
|
|
||||||
// Construct new block index object
|
// Construct new block index object
|
||||||
CBlockIndex* pindexNew = new CBlockIndex(block);
|
CBlockIndex* pindexNew = new CBlockIndex(block);
|
||||||
assert(pindexNew);
|
|
||||||
// We assign the sequence id to blocks only when the full data is available,
|
// We assign the sequence id to blocks only when the full data is available,
|
||||||
// to avoid miners withholding blocks but broadcasting headers, to get a
|
// to avoid miners withholding blocks but broadcasting headers, to get a
|
||||||
// competitive advantage.
|
// competitive advantage.
|
||||||
@ -3443,8 +3442,6 @@ CBlockIndex * InsertBlockIndex(uint256 hash)
|
|||||||
|
|
||||||
// Create new
|
// Create new
|
||||||
CBlockIndex* pindexNew = new CBlockIndex();
|
CBlockIndex* pindexNew = new CBlockIndex();
|
||||||
if (!pindexNew)
|
|
||||||
throw std::runtime_error(std::string(__func__) + ": new CBlockIndex failed");
|
|
||||||
mi = mapBlockIndex.insert(std::make_pair(hash, pindexNew)).first;
|
mi = mapBlockIndex.insert(std::make_pair(hash, pindexNew)).first;
|
||||||
pindexNew->phashBlock = &((*mi).first);
|
pindexNew->phashBlock = &((*mi).first);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user