mirror of
https://github.com/monero-project/monero.git
synced 2025-08-23 06:35:04 -04:00
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
This commit is contained in:
parent
bc09766bf9
commit
0564da5fdc
4 changed files with 18 additions and 9 deletions
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue