Skip to content

Commit faebf1d

Browse files
author
MarcoFalke
committed
wallet: Fix use-after-free in WalletBatch::EraseRecords
1 parent 65c05db commit faebf1d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/wallet/walletdb.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1401,13 +1401,13 @@ bool WalletBatch::EraseRecords(const std::unordered_set<std::string>& types)
14011401
}
14021402

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

14061406
std::string type;
14071407
key >> type;
14081408

14091409
if (types.count(type) > 0) {
1410-
if (!m_batch->Erase(key_data)) {
1410+
if (!m_batch->Erase(Span{key_data})) {
14111411
cursor.reset(nullptr);
14121412
m_batch->TxnAbort();
14131413
return false; // erase failed

0 commit comments

Comments
 (0)