Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorHans Goudey <h.goudey@me.com>2022-02-17 18:04:58 +0300
committerHans Goudey <h.goudey@me.com>2022-02-17 18:05:08 +0300
commit114cc47b78769e5aac45f6234eabe5fabc762aed (patch)
treeb29e9da1c03d16cf3ab6a21cf0e9829ba96e57d2 /source
parente240c8c5dbfffca7edde50c3ee09be3967920ca5 (diff)
Fix: Memory leak in recently added curves copy function
Specify that the destination curve must be initialized, and free the existing attributes (which `CustomData_copy` doesn't do).
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/intern/curves_geometry.cc5
1 files changed, 5 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/curves_geometry.cc b/source/blender/blenkernel/intern/curves_geometry.cc
index 38cf3d351bd..ac40b7a7aa1 100644
--- a/source/blender/blenkernel/intern/curves_geometry.cc
+++ b/source/blender/blenkernel/intern/curves_geometry.cc
@@ -48,8 +48,13 @@ CurvesGeometry::CurvesGeometry(const int point_size, const int curve_size)
this->runtime = MEM_new<CurvesGeometryRuntime>(__func__);
}
+/**
+ * \note Expects `dst` to be initialized, since the original attributes must be freed.
+ */
static void copy_curves_geometry(CurvesGeometry &dst, const CurvesGeometry &src)
{
+ CustomData_free(&dst.point_data, dst.point_size);
+ CustomData_free(&dst.curve_data, dst.curve_size);
dst.point_size = src.point_size;
dst.curve_size = src.curve_size;
CustomData_copy(&src.point_data, &dst.point_data, CD_MASK_ALL, CD_DUPLICATE, dst.point_size);