diff options
author | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2019-04-29 08:17:32 +0000 |
---|---|---|
committer | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2019-06-14 08:47:29 +0000 |
commit | 0564da5fdc165948ba7c862fb81478f9287a072d (patch) | |
tree | 3a30a0c1ec0c5a8d8fa73b950c7251aa219d1e09 /contrib/epee/src/buffer.cpp | |
parent | abstract_tcp_server2: improve DoS resistance (diff) | |
download | monero-0564da5fdc165948ba7c862fb81478f9287a072d.tar.xz |
ensure no NULL is passed to memcpy
NULL is valid when size is 0, but memcpy uses nonnull attributes,
so let's not poke the bear
Diffstat (limited to 'contrib/epee/src/buffer.cpp')
-rw-r--r-- | contrib/epee/src/buffer.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/contrib/epee/src/buffer.cpp b/contrib/epee/src/buffer.cpp index d637b905e..10ea6de56 100644 --- a/contrib/epee/src/buffer.cpp +++ b/contrib/epee/src/buffer.cpp @@ -64,7 +64,8 @@ void buffer::append(const void *data, size_t sz) size_t reserve = (((size() + sz) * 3 / 2) + 4095) & ~4095; new_storage.reserve(reserve); new_storage.resize(size()); - memcpy(new_storage.data(), storage.data() + offset, storage.size() - offset); + if (size() > 0) + memcpy(new_storage.data(), storage.data() + offset, storage.size() - offset); offset = 0; std::swap(storage, new_storage); } |