diff options
| author | Dan Engelbrecht <[email protected]> | 2023-12-14 04:16:25 -0500 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-12-14 10:16:25 +0100 |
| commit | 4d96ef4d9d2c35243a25d90949d43d0997e3bb44 (patch) | |
| tree | 5f398e0027886aed3d12b625b89014ef83fb8abd | |
| parent | 0.2.37-pre1 (diff) | |
| download | zen-4d96ef4d9d2c35243a25d90949d43d0997e3bb44.tar.xz zen-4d96ef4d9d2c35243a25d90949d43d0997e3bb44.zip | |
Make sure IoBuffer is a valid null-buffer after move operation (#610)
| -rw-r--r-- | CHANGELOG.md | 1 | ||||
| -rw-r--r-- | src/zenbase/include/zenbase/refcount.h | 2 | ||||
| -rw-r--r-- | src/zencore/include/zencore/iobuffer.h | 17 |
3 files changed, 16 insertions, 4 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index b010ff6d1..0c7fceb1a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - Bugfix: Correctly calculate peak disk write size in GC status message - Bugfix: Skip invalid chunks in block store GC when moving existing chunks - Bugfix: Don't use copy of Payloads array when fetching memcached payload in GC +- Bugfix: Make sure IoBuffer is a valid null-buffer after move operation - Improvement: Adjusted and added some trace scopes ## 0.2.36 diff --git a/src/zenbase/include/zenbase/refcount.h b/src/zenbase/include/zenbase/refcount.h index 3afcf467c..6ad49cba2 100644 --- a/src/zenbase/include/zenbase/refcount.h +++ b/src/zenbase/include/zenbase/refcount.h @@ -107,6 +107,8 @@ public: Rhs.m_Ref = nullptr; } + inline void Swap(RefPtr& Rhs) noexcept { std::swap(m_Ref, Rhs.m_Ref); } + private: T* m_Ref = nullptr; template<typename U> diff --git a/src/zencore/include/zencore/iobuffer.h b/src/zencore/include/zencore/iobuffer.h index d891ed55b..b9e503354 100644 --- a/src/zencore/include/zencore/iobuffer.h +++ b/src/zencore/include/zencore/iobuffer.h @@ -337,11 +337,20 @@ public: BorrowedFile }; - inline IoBuffer() = default; - inline IoBuffer(IoBuffer&& Rhs) noexcept = default; - inline IoBuffer(const IoBuffer& Rhs) = default; + inline IoBuffer() = default; + inline IoBuffer(IoBuffer&& Rhs) noexcept + { + m_Core.Swap(Rhs.m_Core); + Rhs.m_Core = NullBufferCore; + } + inline IoBuffer(const IoBuffer& Rhs) = default; inline IoBuffer& operator=(const IoBuffer& Rhs) = default; - inline IoBuffer& operator=(IoBuffer&& Rhs) noexcept = default; + inline IoBuffer& operator =(IoBuffer&& Rhs) noexcept + { + m_Core.Swap(Rhs.m_Core); + Rhs.m_Core = NullBufferCore; + return *this; + } /** Create an uninitialized buffer of the given size */ |