From cf0f43ee42f0bf8d345b109b0ba552faf7cb62e1 Mon Sep 17 00:00:00 2001 From: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz> Date: Thu, 4 Jan 2024 12:18:07 +0100 Subject: [PATCH] wallet: Fix use-after-free in WalletBatch::EraseRecords Github-Pull: bitcoin/bitcoin#29176 Rebased-From: faebf1df2afe207f5d2d4f73f50ac66824fe34bb --- src/wallet/walletdb.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wallet/walletdb.cpp b/src/wallet/walletdb.cpp index 460a5bad595..4f04cdf9121 100644 --- a/src/wallet/walletdb.cpp +++ b/src/wallet/walletdb.cpp @@ -1132,13 +1132,13 @@ bool WalletBatch::EraseRecords(const std::unordered_set& 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) { - m_batch->Erase(key_data); + m_batch->Erase(Span{key_data}); } } return true;