Skip to content

Commit f6875bd

Browse files
committed
fix use after free in peg-in mempool logic
1 parent ea9d92d commit f6875bd

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

src/txmempool.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -635,14 +635,15 @@ void CTxMemPool::removeForBlock(const std::vector<CTransactionRef>& vtx, unsigne
635635
for (std::set<std::pair<uint256, COutPoint> >::const_iterator it = setPeginsSpent.begin(); it != setPeginsSpent.end(); it++) {
636636
std::map<std::pair<uint256, COutPoint>, uint256>::const_iterator it2 = mapWithdrawsSpentToTxid.find(*it);
637637
if (it2 != mapWithdrawsSpentToTxid.end()) {
638-
txiter txit = mapTx.find(it2->second);
638+
uint256 tx_id = it2->second;
639+
txiter txit = mapTx.find(tx_id);
639640
assert(txit != mapTx.end());
640641
const CTransaction& tx = txit->GetTx();
641642
setEntries stage;
642643
stage.insert(txit);
643644
RemoveStaged(stage, true);
644645
removeRecursive(tx, MemPoolRemovalReason::CONFLICT);
645-
ClearPrioritisation(it2->second);
646+
ClearPrioritisation(tx_id);
646647
}
647648
}
648649
lastRollingFeeUpdate = GetTime();

0 commit comments

Comments
 (0)