From 5d608a635bd952824c8a7425f54d65fcbd3ea5b3 Mon Sep 17 00:00:00 2001 From: Thomas Padioleau Date: Tue, 29 Mar 2022 10:11:58 +0200 Subject: [PATCH] Free memory before copying other pointer --- include/ddc/chunk.hpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/ddc/chunk.hpp b/include/ddc/chunk.hpp index d1ca3e001..828c2171d 100644 --- a/include/ddc/chunk.hpp +++ b/include/ddc/chunk.hpp @@ -119,6 +119,9 @@ class Chunk, Allocator> Chunk& operator=(Chunk&& other) { assert(this != &other); + if (this->m_internal_mdspan.data()) { + std::allocator_traits::deallocate(m_allocator, this->data(), this->size()); + } static_cast(*this) = std::move(static_cast(other)); m_allocator = std::move(other.m_allocator);