mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-17 13:07:54 +02: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:
parent
71300489af
commit
84b2f353bb
3 changed files with 8 additions and 0 deletions
|
|
@ -409,6 +409,7 @@ bool SQLiteBatch::ReadKey(DataStream&& key, DataStream& value)
|
|||
// Leftmost column in result is index 0
|
||||
const std::byte* data{AsBytePtr(sqlite3_column_blob(m_read_stmt, 0))};
|
||||
size_t data_size(sqlite3_column_bytes(m_read_stmt, 0));
|
||||
value.clear();
|
||||
value.write({data, data_size});
|
||||
|
||||
sqlite3_clear_bindings(m_read_stmt);
|
||||
|
|
@ -495,6 +496,9 @@ DatabaseCursor::Status SQLiteCursor::Next(DataStream& key, DataStream& value)
|
|||
return Status::FAIL;
|
||||
}
|
||||
|
||||
key.clear();
|
||||
value.clear();
|
||||
|
||||
// Leftmost column in result is index 0
|
||||
const std::byte* key_data{AsBytePtr(sqlite3_column_blob(m_cursor_stmt, 0))};
|
||||
size_t key_data_size(sqlite3_column_bytes(m_cursor_stmt, 0));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue