mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-11 06:28:31 +01:00
walletdb: Consistently clear key and value streams before writing
Before writing data to the output key and value streams, make sure they are cleared.
This commit is contained in:
@@ -100,6 +100,8 @@ DatabaseCursor::Status MockableCursor::Next(DataStream& key, DataStream& value)
|
||||
if (m_cursor == m_cursor_end) {
|
||||
return Status::DONE;
|
||||
}
|
||||
key.clear();
|
||||
value.clear();
|
||||
const auto& [key_data, value_data] = *m_cursor;
|
||||
key.write(key_data);
|
||||
value.write(value_data);
|
||||
@@ -117,6 +119,7 @@ bool MockableBatch::ReadKey(DataStream&& key, DataStream& value)
|
||||
if (it == m_records.end()) {
|
||||
return false;
|
||||
}
|
||||
value.clear();
|
||||
value.write(it->second);
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user