image : fix buffer's copy ctor - only std::copy when rhs owns the data (#3152)
This commit is contained in:
parent
34f5b56003
commit
cb31692f37
1 changed files with 3 additions and 2 deletions
|
@ -59,10 +59,11 @@ buffer::buffer(buffer && rhs) noexcept
|
|||
// copy
|
||||
buffer::buffer(buffer const& rhs)
|
||||
: size_(rhs.size_),
|
||||
data_(static_cast<unsigned char*>(size_ != 0 ? ::operator new(size_) : nullptr)),
|
||||
owns_(true)
|
||||
data_(static_cast<unsigned char*>((rhs.owns_ && size_ != 0) ? ::operator new(size_) : nullptr)),
|
||||
owns_(rhs.owns_)
|
||||
{
|
||||
if (data_) std::copy(rhs.data_, rhs.data_ + rhs.size_, data_);
|
||||
else data_ = rhs.data_;
|
||||
}
|
||||
|
||||
buffer::~buffer()
|
||||
|
|
Loading…
Reference in a new issue