2020#include < reverse_iterator.h>
2121#include < util/check.h>
2222#include < util/moneystr.h>
23+ #include < util/overflow.h>
2324#include < util/system.h>
2425#include < util/time.h>
2526#include < validationinterface.h>
@@ -102,9 +103,9 @@ CTxMemPoolEntry::CTxMemPoolEntry(const CTransactionRef& tx, CAmount fee,
102103
103104void CTxMemPoolEntry::UpdateModifiedFee (CAmount fee_diff)
104105{
105- nModFeesWithDescendants += fee_diff;
106- nModFeesWithAncestors += fee_diff;
107- m_modified_fee += fee_diff;
106+ nModFeesWithDescendants = SaturatingAdd (nModFeesWithDescendants, fee_diff) ;
107+ nModFeesWithAncestors = SaturatingAdd (nModFeesWithAncestors, fee_diff) ;
108+ m_modified_fee = SaturatingAdd (m_modified_fee, fee_diff) ;
108109}
109110
110111void CTxMemPoolEntry::UpdateLockPoints (const LockPoints& lp)
@@ -459,7 +460,7 @@ void CTxMemPoolEntry::UpdateDescendantState(int64_t modifySize, CAmount modifyFe
459460{
460461 nSizeWithDescendants += modifySize;
461462 assert (int64_t (nSizeWithDescendants) > 0 );
462- nModFeesWithDescendants += modifyFee;
463+ nModFeesWithDescendants = SaturatingAdd (nModFeesWithDescendants, modifyFee) ;
463464 nCountWithDescendants += modifyCount;
464465 assert (int64_t (nCountWithDescendants) > 0 );
465466}
@@ -468,7 +469,7 @@ void CTxMemPoolEntry::UpdateAncestorState(int64_t modifySize, CAmount modifyFee,
468469{
469470 nSizeWithAncestors += modifySize;
470471 assert (int64_t (nSizeWithAncestors) > 0 );
471- nModFeesWithAncestors += modifyFee;
472+ nModFeesWithAncestors = SaturatingAdd (nModFeesWithAncestors, modifyFee) ;
472473 nCountWithAncestors += modifyCount;
473474 assert (int64_t (nCountWithAncestors) > 0 );
474475 nSigOpCostWithAncestors += modifySigOps;
@@ -1018,7 +1019,7 @@ void CTxMemPool::PrioritiseTransaction(const uint256& hash, const CAmount& nFeeD
10181019 {
10191020 LOCK (cs);
10201021 CAmount &delta = mapDeltas[hash];
1021- delta += nFeeDelta;
1022+ delta = SaturatingAdd (delta, nFeeDelta) ;
10221023 txiter it = mapTx.find (hash);
10231024 if (it != mapTx.end ()) {
10241025 mapTx.modify (it, [&nFeeDelta](CTxMemPoolEntry& e) { e.UpdateModifiedFee (nFeeDelta); });
0 commit comments