aboutsummaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2018-02-18 13:45:43 +0000
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2018-02-18 14:02:36 +0000
commit4789f8598f5f6a4638e19d0ed8ccf1e625438357 (patch)
treeca41bcecfbbc2d41d9370a48d7f628ea34d9cdcd /contrib
parentMerge pull request #3275 (diff)
downloadmonero-4789f8598f5f6a4638e19d0ed8ccf1e625438357.tar.xz
wipeable_string: don't try to wipe an empty buffer
memset_s doesn't like it
Diffstat (limited to 'contrib')
-rw-r--r--contrib/epee/src/wipeable_string.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/contrib/epee/src/wipeable_string.cpp b/contrib/epee/src/wipeable_string.cpp
index cc43b8988..6ed4ee8a2 100644
--- a/contrib/epee/src/wipeable_string.cpp
+++ b/contrib/epee/src/wipeable_string.cpp
@@ -76,7 +76,8 @@ wipeable_string::~wipeable_string()
void wipeable_string::wipe()
{
- memwipe(buffer.data(), buffer.size() * sizeof(char));
+ if (!buffer.empty())
+ memwipe(buffer.data(), buffer.size() * sizeof(char));
}
void wipeable_string::grow(size_t sz, size_t reserved)
@@ -93,11 +94,13 @@ 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));
- memwipe(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));
- memwipe(tmp.get(), old_sz * sizeof(char));
+ if (old_sz > 0)
+ memwipe(tmp.get(), old_sz * sizeof(char));
}
void wipeable_string::push_back(char c)