Skip to content

Commit 9519573

Browse files
committed
Fix Bytes move assignment
1 parent d3bb3a9 commit 9519573

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

src/paimon/common/memory/bytes.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,16 @@ Bytes& Bytes::operator=(Bytes&& other) noexcept {
5959
if (&other == this) {
6060
return *this;
6161
}
62-
this->~Bytes();
63-
std::memcpy(this, &other, sizeof(*this));
64-
new (&other) Bytes();
62+
if (data_ != nullptr) {
63+
assert(pool_);
64+
pool_->Free(data_, size_);
65+
}
66+
pool_ = other.pool_;
67+
data_ = other.data_;
68+
size_ = other.size_;
69+
other.pool_ = nullptr;
70+
other.data_ = nullptr;
71+
other.size_ = 0;
6572
return *this;
6673
}
6774

0 commit comments

Comments
 (0)