diff options
author | Hans Goudey <h.goudey@me.com> | 2022-10-19 21:12:20 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2022-10-19 21:12:20 +0300 |
commit | c14b1137464708cccc9034e8abfd509f55c8ca85 (patch) | |
tree | 40f795e88fdd430f4c8718d5c378b120b5a46e9b /source/blender/blenkernel/intern | |
parent | a803dbe7ed80df577b648f9e289aaed2a2cc1700 (diff) |
Fix: Geometry Nodes: Memory leak when deleting instances
The instance attributes assignment operators were broken in multiple
ways: there wasn't a move constructor (probably causing performance
issues), and the destination attributes weren't freed before they
were replaced.
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r-- | source/blender/blenkernel/intern/attribute_access.cc | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/source/blender/blenkernel/intern/attribute_access.cc b/source/blender/blenkernel/intern/attribute_access.cc index b86353bdb74..544427cfdd3 100644 --- a/source/blender/blenkernel/intern/attribute_access.cc +++ b/source/blender/blenkernel/intern/attribute_access.cc @@ -642,15 +642,26 @@ CustomDataAttributes::CustomDataAttributes(CustomDataAttributes &&other) size_ = other.size_; data = other.data; CustomData_reset(&other.data); + other.size_ = 0; } CustomDataAttributes &CustomDataAttributes::operator=(const CustomDataAttributes &other) { - if (this != &other) { - CustomData_copy(&other.data, &data, CD_MASK_ALL, CD_DUPLICATE, other.size_); - size_ = other.size_; + if (this == &other) { + return *this; } + this->~CustomDataAttributes(); + new (this) CustomDataAttributes(other); + return *this; +} +CustomDataAttributes &CustomDataAttributes::operator=(CustomDataAttributes &&other) +{ + if (this == &other) { + return *this; + } + this->~CustomDataAttributes(); + new (this) CustomDataAttributes(std::move(other)); return *this; } |