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:
moneromooo-monero 2019-04-29 08:17:32 +00:00
parent bc09766bf9
commit 0564da5fdc
No known key found for this signature in database
GPG key ID: 686F07454D6CEFC3
4 changed files with 18 additions and 9 deletions

View file

@ -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);
}