mirror of
https://codeberg.org/anoncontributorxmr/monero.git
synced 2024-11-26 21:03:28 +01:00
wipeable_string: don't try to wipe an empty buffer
memset_s doesn't like it
This commit is contained in:
parent
4f80c50730
commit
4789f8598f
@ -76,6 +76,7 @@ wipeable_string::~wipeable_string()
|
||||
|
||||
void wipeable_string::wipe()
|
||||
{
|
||||
if (!buffer.empty())
|
||||
memwipe(buffer.data(), buffer.size() * sizeof(char));
|
||||
}
|
||||
|
||||
@ -93,10 +94,12 @@ void wipeable_string::grow(size_t sz, size_t reserved)
|
||||
size_t old_sz = buffer.size();
|
||||
std::unique_ptr<char[]> tmp{new char[old_sz]};
|
||||
memcpy(tmp.get(), buffer.data(), old_sz * sizeof(char));
|
||||
if (old_sz > 0)
|
||||
memwipe(buffer.data(), old_sz * sizeof(char));
|
||||
buffer.reserve(reserved);
|
||||
buffer.resize(sz);
|
||||
memcpy(buffer.data(), tmp.get(), old_sz * sizeof(char));
|
||||
if (old_sz > 0)
|
||||
memwipe(tmp.get(), old_sz * sizeof(char));
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user