Skip to content

Commit

Permalink
wallet: Fix use-after-free in WalletBatch::EraseRecords
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoFalke committed Jan 4, 2024
1 parent 65c05db commit faebf1d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/wallet/walletdb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1401,13 +1401,13 @@ bool WalletBatch::EraseRecords(const std::unordered_set<std::string>& types)
}

// Make a copy of key to avoid data being deleted by the following read of the type
Span key_data{key};
const SerializeData key_data{key.begin(), key.end()};

std::string type;
key >> type;

if (types.count(type) > 0) {
if (!m_batch->Erase(key_data)) {
if (!m_batch->Erase(Span{key_data})) {
cursor.reset(nullptr);
m_batch->TxnAbort();
return false; // erase failed
Expand Down

0 comments on commit faebf1d

Please sign in to comment.