[Bf-blender-cvs] [114cc47b787] master: Fix: Memory leak in recently added curves copy function
Hans Goudey
noreply at git.blender.org
Thu Feb 17 16:05:20 CET 2022
Commit: 114cc47b78769e5aac45f6234eabe5fabc762aed
Author: Hans Goudey
Date: Thu Feb 17 09:04:58 2022 -0600
Branches: master
https://developer.blender.org/rB114cc47b78769e5aac45f6234eabe5fabc762aed
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).
===================================================================
M source/blender/blenkernel/intern/curves_geometry.cc
===================================================================
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);
More information about the Bf-blender-cvs
mailing list