util/AllocatedArray: copy constructor copies "nulled" state

This commit is contained in:
Max Kellermann 2019-12-09 09:39:36 +01:00 committed by Max Kellermann
parent 2cc1dd28cd
commit aee861c009

View File

@ -62,11 +62,13 @@ public:
assert(size() == 0 || buffer.data != nullptr);
}
explicit AllocatedArray(const AllocatedArray &other) noexcept
:buffer{new T[other.buffer.size], other.buffer.size} {
assert(size() == 0 || buffer.data != nullptr);
explicit AllocatedArray(const AllocatedArray &other) noexcept {
assert(other.size() == 0 || other.buffer.data != nullptr);
if (other == nullptr)
return;
buffer = {new T[other.buffer.size], other.buffer.size};
std::copy_n(other.buffer.data, buffer.size, buffer.data);
}