aboutsummaryrefslogtreecommitdiff
path: root/contrib/epee
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2017-12-19 11:55:45 +0000
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2017-12-19 11:55:45 +0000
commit9ec44a2b06799709fcba197372f596f85f74feb8 (patch)
tree28fede65efbb2bf3d7fcebc188e6e714e89b0b52 /contrib/epee
parentMerge pull request #2134 (diff)
downloadmonero-9ec44a2b06799709fcba197372f596f85f74feb8.tar.xz
wipeable_string: fix clear and push_back
Diffstat (limited to 'contrib/epee')
-rw-r--r--contrib/epee/src/wipeable_string.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/contrib/epee/src/wipeable_string.cpp b/contrib/epee/src/wipeable_string.cpp
index 75191df71..c8fed7bb3 100644
--- a/contrib/epee/src/wipeable_string.cpp
+++ b/contrib/epee/src/wipeable_string.cpp
@@ -89,7 +89,10 @@ void wipeable_string::grow(size_t sz, size_t reserved)
reserved = sz;
CHECK_AND_ASSERT_THROW_MES(reserved >= sz, "reserved < sz");
if (reserved <= buffer.capacity())
+ {
+ buffer.resize(sz);
return;
+ }
size_t old_sz = buffer.size();
std::unique_ptr<char[]> tmp{new char[old_sz]};
memcpy(tmp.get(), buffer.data(), old_sz * sizeof(char));
@@ -103,7 +106,7 @@ void wipeable_string::grow(size_t sz, size_t reserved)
void wipeable_string::push_back(char c)
{
grow(size() + 1);
- buffer.push_back(c);
+ buffer.back() = c;
}
void wipeable_string::pop_back()